Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access 2010 Between statement returns both positive and negative values

Posted on 2013-12-27
6
Medium Priority
?
410 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 49

Expert Comment

by:Dale Fye
ID: 39742370
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39742435
< 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
ID: 39742441
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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 49

Accepted Solution

by:
Dale Fye earned 1500 total points
ID: 39742466
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
ID: 39742505
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 49

Expert Comment

by:Dale Fye
ID: 39742601
Glad I could help
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

963 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