Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DAO sql query

Status
Not open for further replies.

FireViking

Programmer
Jun 29, 2001
64
AU
Hi all,
I have a query written in code to count records within a table. The query needs to pull information on 4 criteria.
I can get the query to work on 2 criteria but as soon as I try the third it fails.

The code is as follows:

Set rs.openrecordset("Select * from tblSummons where CaseWon = False and CustomerID =" & CustomerID)

this code works fine. I need to add 2 more criteria, those being CaseLost and Withdrawn.

I have tried

Set rs.openrecordset("Select * from tblSummons where CaseWon = False or CaseLost = False and CustomerID =" & CustomerID)
is the "or" the correct syntax or do I need brackets?

I am sure that this is not the right syntax so if any one can help it would be appreciated.

 

Parentheses help clarify the meaning of your criteria and eliminate ambiguity. Try adding appropriate parens to your query.

Example:
Set rs.openrecordset("Select * from tblSummons where (CaseWon = False Or CaseLost = False) and CustomerID =" & CustomerID)
Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top