Solved

Access query criteria

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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.​
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 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