strSQL = " (multiple criteria)

C

Chrissy

I am using a date criteria strSQL I got from here a while back. Works great!
Thanks.

Now I wish to add a second criteria to it. I am so lost.

Successful code:
strSql = "[StartDate] >= #" & CDate(Me!txtStartDate) & "# AND [StartDate] <
1+ #" & CDate(Me!txtEndDate) & "#"


What I would like to include above: And [CG1] = Me.txtCGID

This would limit results to the date range for the employee (CG1) selected.
Don't have a clue how to do this and cannot seem to find any examples.

Help?
 
K

ken

If CG1 is a number data type then:

strSql = "[StartDate] >= #" & CDate(Me!txtStartDate) & _
"# AND [StartDate] < 1+ #" & CDate(Me!txtEndDate) & _
"# AND [CGI] = " & Me.txtCGID

If it’s a text data type then:

strSql = "[StartDate] >= #" & CDate(Me!txtStartDate) & _
"# AND [StartDate] < 1+ #" & CDate(Me!txtEndDate) & _
"# AND [CGI] = """ & Me.txtCGID & """"

Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top