[RESOLVED] Select with multiple conditions
I have some code where this works fine
Code:
With rs
.Open "SELECT * FROM Requests where RequestType = '" & Cells(Target.Row, 1) & "'", cn, adOpenKeyset, adLockOptimistic, adCmdText
.Fields("Status").Value = Cells(Target.Row, 4).Value
.Fields("Notes").Value = Cells(Target.Row, 6).Value
.Update
End With
I'm trying to add a second condition and the syntax is wrong. What's my mistake?
Code:
.Open "SELECT * FROM Requests where RequestType = '" & Cells(Target.Row, 1) & "' AND DateCreated = '" & cells(target.Row, 2) & "'", cn, adOpenKeyset, adLockOptimistic, adCmdText
Re: Select with multiple conditions
dates should be enclosed in # rather than '
also date formats are critical (mm/dd/yy) it may be 4 digit year, i am not sure on that
Re: Select with multiple conditions
Thanks but it's a syntax error not a wrong result and in any case this (where I've just duplicated the working part) isn't correct either
.Open "SELECT * FROM Requests where RequestType = '" & Cells(Target.Row, 1) & "' AND RequestType = '" & cells(target.Row, 1) & "'", cn, adOpenKeyset, adCmdText"
Re: Select with multiple conditions
Never mind, there was a quote at the end.