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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2000 VBA SELECT / WHERE (multiple) 1

Status
Not open for further replies.

DWSwaim

Programmer
Jan 22, 2004
4
US
Multiple WHERE arguments.
I have seen multiple WHERE values used but I am having problems getting VBA to accept my attempts. Does Acess/VBA support this option? My code looks like this:

strSQL = "SELECT * FROM [Recruitment Event History] WHERE Recruitment_Location_ID = " & intLocation & " and Recruitment_Term = " & strTerm & " and Recruitment_Year =" & intYear

Set qdfstrQname = dbsDatabase.CreateQueryDef(strQname, strSQL)

I've tried different variations of this code but no luck so far.
Thanks
Darrell
 
Darrell,
You need quotes around the character criterion:

strSQL = "SELECT * FROM [Recruitment Event History] WHERE Recruitment_Location_ID = " & intLocation & " and Recruitment_Term = '" & strTerm & "' and Recruitment_Year =" & intYear

(Note the single quotes inserted before and after strTerm)

Let me know if this doesn't work.
Tranman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top