Solved

Access query criteria

Posted on 2013-01-28
4
162 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Worked like a charm....old Excel jockies die hard....
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
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.…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

14 Experts available now in Live!

Get 1:1 Help Now