Solved

Access 2010 Between statement returns both positive and negative values

Posted on 2013-12-27
6
383 Views
Last Modified: 2013-12-27
I am using a between statement to pull 2 values from a text box in a form and return the fields that are between these values.  The field in question is a calculated field in another query and is joined to this query.  My problem:  my statement is treating the values as absolutes and is returning those in the between range that are both positive and negative.

For example, I have values that are 255, 376, 115, 543, -36, -125, -444.  If I send values to the between statement that are between 200 and 400, I get 255, 376, 543, and -444.

Please advise.
0
Comment
Question by:jwandmrsquared
  • 3
  • 2
6 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
Comment Utility
You need to provide the syntax you are using so that we can interpret what is going wrong.

I'm assuming this is a SQL statement?
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
< The field in question is a calculated field in another query and is joined to this query.>

in which field  did you place the "Between criteria" ?
   - in the calculated field in another query ?
0
 

Author Comment

by:jwandmrsquared
Comment Utility
SELECT qry_pplc_all_action_items_to_email.Item_Status, qry_pplc_all_action_items_to_email.PPLCREV, qry_pplc_all_action_items_to_email.[Product ID], qry_pplc_all_action_items_to_email.[Product Action Items], qry_pplc_all_action_items_to_email.Resolution, qry_pplc_all_action_items_to_email.[Resolve Date], qry_pplc_all_action_items_to_email.AI_Owner, qry_pplc_all_action_items_to_email.AI_Owner_email, qry_pplc_all_action_items_to_email.[Product Name], qry_pplc_all_action_items_to_email.[Days to Orig Due Date], qry_pplc_all_action_items_to_email.[Days to Revised Date], qry_pplc_all_action_items_to_email.[Days to last email]
FROM qry_pplc_all_action_items_to_email
WHERE (((qry_pplc_all_action_items_to_email.[Days to Orig Due Date]) Between [Forms]![frm_pplc_email_ais]![orig_due_From] And [Forms]![frm_pplc_email_ais]![orig_due_to]));


Days to Orig Due Date is calculated.

orig_due_From and orig_due_to are text boxes.

Here is the sql that calculates the date field(s):
SELECT tbl_product_PPL_Court_Followup_LIs.pplc_AI_Key, Max(tbl_product_PPL_Court_Followup_LIs.email_date) AS MaxOfemail_date, Max(tbl_product_PPL_Court_Followup_LIs.follow_up_date) AS MaxOffollow_up_date, Max(tbl_product_PPL_Court_Followup_LIs.rsvd_due_date) AS MaxOfrsvd_due_date
FROM tbl_product_PPL_Court_Followup_LIs
GROUP BY tbl_product_PPL_Court_Followup_LIs.pplc_AI_Key;



for info purposes - maxoffollow_up_date is Days to Orig Due Date on the top query.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
Comment Utility
SELECT qry_pplc_all_action_items_to_email.Item_Status
           , qry_pplc_all_action_items_to_email.PPLCREV
           , qry_pplc_all_action_items_to_email.[Product ID]
           , qry_pplc_all_action_items_to_email.[Product Action Items]
           , qry_pplc_all_action_items_to_email.Resolution
           , qry_pplc_all_action_items_to_email.[Resolve Date]
           , qry_pplc_all_action_items_to_email.AI_Owner
           , qry_pplc_all_action_items_to_email.AI_Owner_email
           , qry_pplc_all_action_items_to_email.[Product Name]
           , qry_pplc_all_action_items_to_email.[Days to Orig Due Date]
           , qry_pplc_all_action_items_to_email.[Days to Revised Date]
           , qry_pplc_all_action_items_to_email.[Days to last email]
FROM qry_pplc_all_action_items_to_email
WHERE qry_pplc_all_action_items_to_email.[Days to Orig Due Date]
Between [Forms]![frm_pplc_email_ais]![orig_due_From]
And [Forms]![frm_pplc_email_ais]![orig_due_to]

Have you defined these parameters for the query?  Chances are that it may be interpreting those form control values as text, not numbers.  You can create the parameters by right clicking in the top of the query design grid and selecting parameters.parametersThen copy your parameters:

[Forms]![frm_pplc_email_ais]![orig_due_From]
[Forms]![frm_pplc_email_ais]![orig_due_to]

to two successive lines (the top two) and select the data types.  Then open your form, enter your parameters and rerun the query.
0
 

Author Closing Comment

by:jwandmrsquared
Comment Utility
I also had to set the text boxes to format Fixed, but the parameters finished it off.  The minute you said it, the dust fell off my brain.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
Comment Utility
Glad I could help
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now