SQL string using LIke

greenguy

Registered User.
Local time
Today, 13:32
Joined
Oct 30, 2007
Messages
36
Howdy I keep getting a missing operator error when I try to execute this SQL string. I've looked at it too long and can't find the issue. Can someone with a fresh set of eyes take a look?

strsearch = Nz(Me.txtsearch.Value)
strsearch = "*" & strsearch & "*"
strSQL = "SELECT * FROM tblmasterlist"
strSQL = strSQL & " WHERE((([Description])Like " & strsearch & "));"
MsgBox strSQL

Thansk in advance for the help!
 
I agree with dcb on this. You are missing quotes for a text string.

I like using the Chr(34) for the double quotes as it sometimes is easier to understand than triple and double double quotes.
Code:
strsearch = Nz(Me.txtsearch,"")
strsearch = "*" & strsearch & "*"
strSQL = "SELECT * FROM tblmasterlist"
strSQL = strSQL & " WHERE [Description] Like " [COLOR="Red"]& Chr(34) &[/COLOR] strsearch & [COLOR="red"]Chr(34) &[/COLOR] "));"
 
Oh, and you really don't need all of those parens in the Where.
 
I have always wondered why they are there in the first place as I always take them out though it does not seem to matter whether or not they are there even in ASP.Net.

As Bob mentioned it is alway worth an ask!

Simon
 
Hi guys, I realize this is a bit late but I've been gone for a while. Prison is nasty, :D Only kidding. Of course the proposed fix worked perfect as usual! Thanks a bunch for the help!
 

Users who are viewing this thread

Back
Top Bottom