Solved

Access query criteria

Posted on 2013-01-28
4
167 Views
Last Modified: 2013-01-28
I have a query that limits the records based on a time frame.  Here is the code:

WHERE (((tblGeneral.dtaDueDate)>Now()-180 And (tblGeneral.dtaDueDate)<Now()-7) AND ((tblGeneral.dtaEstValue)=0))

This also limits the records to the records where dtaEstValue = Zero.

When I add another criteria, the first criteria seems to be disregarded where the date limitations do not apply:


WHERE (((tblGeneral.dtaDueDate)>Now()-180 And (tblGeneral.dtaDueDate)<Now()-7) AND ((tblGeneral.dtaEstValue)=0)) OR (((tblGeneral.[dtaEstLabor$])=0));


Why when I add the "OR" clause to limit the records selected where one or both fieds are zero.  I want to add more "OR" statements for additional fields, but cannot get this one to work.  The goal is to show the records that fall between the date parameters and also have a zero in any of the other fields.
0
Comment
Question by:actolex
[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
  • 2
4 Comments
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38829685
WHERE (dtaDueDate>Now()-180 And tblGeneral.dtaDueDate<Now()-7) AND (tblGeneral.dtaEstValue=0 OR [dtaEstLabor$])=0)
0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 500 total points
ID: 38829687
Your parenthesis where in the wrong place.
WHERE (dtaDueDate>Now()-180 And tblGeneral.dtaDueDate<Now()-7) AND (tblGeneral.dtaEstValue=0 OR [dtaEstLabor$]=0)

Open in new window


Ignore my first post. I accidentally submitted it.
0
 
LVL 4

Expert Comment

by:MimicTech
ID: 38829690
WHERE
   ( tblGeneral.dtaDueDate > (Now()-180) )
   And 
   ( tblGeneral.dtaDueDate < (Now()-7) )
   And
   (
      tblGeneral.dtaEstValue = 0
      OR 
      tblGeneral.[dtaEstLabor$] = 0
      OR
      ...
   );

Open in new window

0
 

Author Closing Comment

by:actolex
ID: 38829720
Worked like a charm....old Excel jockies die hard....
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Currency in SQL? 2 45
How to structure query with count aggregate 4 47
add criteria to query in VB, Access 2003 2 33
compare date to getdate() 8 18
Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 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