quotes and apostrophes in coded query

BigJimSlade

Registered User.
Local time
Today, 13:05
Joined
Oct 11, 2000
Messages
173
Hey, Big Jim here:

I have a query somewhat like this:

txtTest.text = Mike's "D" Licious Salads

Docmd.RunSQL(Select * FROM Table WHERE Name = '" & txtTest.text & "' ;")

Anyhow, I get an error because of the quotes around the D and/or the apostrophe in Mike's pending on how I write the code. How could I write this query so that it would accept both the apostrophe and the quotes?


Thanks in advance!

Big Jim
 
Hi Jack!

The solution you directed me to looks great, but how would I place the chr(34) into the middle of the string txtTest.text on either side of the quotes?

Thanks for all of your help!

Big Jim
 
I haven't had time to look at the problem but I have a feeling that you will have to use this for the name: Mike's 'D' Licious Salads

I will try to take a look at this a bit later on but the above should work as a temporary and possibly permanent solution.

Jack
 
'Access 2000 and Up

Code:
Dim stString as String
txtTest.text = Mike's "D" Licious Salads 

'Doubles up the '
stString=Replace(txtTest.text,"'","''")

'Doubles up the "
stString=Replace(stString,""","""")

Docmd.RunSQL(Select * FROM Table WHERE Name = '" & stString & "' ;")
 
Travis! Jack!

Thanks for all of your help. It looks like a great solution you found there.

Thanks again!

Big Jim
 
That was a very slick idea from Travis! That solution NEVER would have come to my mind. Well done Travis....

Jack
 

Users who are viewing this thread

Back
Top Bottom