Solved

Access 2010 Between statement returns both positive and negative values

Posted on 2013-12-27
6
396 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 48

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
Technology Partners: 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!

 
LVL 48

Accepted Solution

by:
Dale Fye earned 500 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 48

Expert Comment

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

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

632 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