Depends on how you're delimiting the string in your SQL statement.
If you're using a single quote to delimit, you need to change all
occurrences of single quotes in the string to two single quotes in a row:
"... WHERE MyName = '" & Replace(strValue, "'", "''") & "'"
Exagerated for clarity:
"... WHERE MyName = ' " & Replace(strValue, " ' ", " ' ' ") & " ' "
On the other hand, if you're using a double quote to delimit, you need to
change all occurrences of double quotes to two double quotes in a row:
"... WHERE MyName = " & Chr$(34) & Replace(strValue, Chr$(34), Chr$(34) &
Chr$(34)) & Chr$(34)
(In case you weren't aware, Chr$(34) is the same as ")
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Stefania Scott" <st******@u.arizona.edu> wrote in message
news:3e**************************@posting.google.c om...
How do I resolve the problem of passing a string that has quotes
within in a SQL statement? Sometimes the string contains a single
quote (') and some others it contains the double quote (")?
Any clue...
Thank you,
Stefania