Link to home
Start Free TrialLog in
Avatar of thandel
thandel

asked on

SQL Syntax

I am trying to run an SQL command ... I have it working as:

sSql = "SELECT * FROM tClaim WHERE ClaimNo = " & """" & sLab & """"

but I need to do a wild card search and trim the variable..... so I tried this:

sSql = "SELECT * FROM tClaim WHERE ClaimNo Like "" * "" & Trim(sLab) & "" * """

This just ends up freezing up MS Access.

What is wrong with my SQL statement looking for a wild card?

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Paul Jackson
Paul Jackson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
try like:

sSql = "SELECT * FROM tClaim WHERE ClaimNo Like '*" & Replace(Trim(sLab),"'","''") & "*' "

Open in new window

Avatar of thandel
thandel

ASKER

Thanks I edited my question and had removed the equal sign but missed the single quotes.... that worked thanks Paul!
anyway...

this part :  

Like " & "'*" 

Open in new window


can be simplified to as what I already shown