VBA sql statement

raindrop3

Registered User.
Local time
Today, 17:43
Joined
Sep 6, 2001
Messages
98
Morning!

I have a little problem, but big enough for me to play with it for hours, and still I haven't found the solution. Time to ask help.

This is my SQL-statement:

sql = "SELECT * FROM Music WHERE artist = '" & sArtist & "' AND title = '" & sTitle & "';"

The problem: when a ' (apostroph?) occur in e.g. the title, the statement won't find a result, while there IS a result.

When no ' (apostroph?) occurs in e.g. the title, the statement find a result!

Does anyone know a sql statement that find results in both cases? (A title with a apostrop or without)

Thanks a lot.

Greetings,

Albert
 
Follow this link to the part about Including Double Quotation Marks

Click Here
 
I would have used

sql = "SELECT * FROM Music WHERE ([artist] = """ & sArtist & """ AND [title] = """ & sTitle & """)"

Should work

Stu
 
WOW!

Thanks a lot, StuBailey! It works now. Quit simple... :D

Greetings,

Albert
 

Users who are viewing this thread

Back
Top Bottom