Solved

Access query criteria

Posted on 2013-01-28
4
163 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
another query question 7 36
mySQL Syntax 7 34
Need help subtracting a value within my script 7 42
Updating a table from a temp table 4 29
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

896 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

12 Experts available now in Live!

Get 1:1 Help Now