SQl statement with two where conditions

foxtrot123

Registered User.
Local time
Today, 11:02
Joined
Feb 18, 2010
Messages
57
For the life of me I cannot get the correct syntax for this. The punctuation for the second where condition is incorrect. Any suggestions?

Code:
Me.cboDose.RowSource = "SELECT Label FROM tblLookup WHERE tblLookup.[Med]='" & Me.cboMed & "'" AND tblLookup.[Notes] = "Swallowed"
 
I believe you need to put single quotes around the word Swallowed and lose a double quote before AND tblLookup.

Code:
Me.cboDose.RowSource = "SELECT Label FROM tblLookup WHERE tblLookup.[Med]='" & Me.cboMed & "'[COLOR="Red"]"[/COLOR] AND tblLookup.[Notes] = "Swallowed"

becomes

Me.cboDose.RowSource = "SELECT Label FROM tblLookup WHERE tblLookup.[Med]='" & Me.cboMed & "' AND tblLookup.[Notes] = [COLOR="Red"]'Swallowed'[/COLOR]"
 
That was it! Thank you.
 
You're welcome. :)

Sometimes it just requires a second pair of eyes to see things that we miss.
 

Users who are viewing this thread

Back
Top Bottom