Single quote

S

Souris

I use a list box information to insert user's comments.

I have following SQL statement:

"INSERT INTO MYTABLE
SET COMMENTS = ME!MYLISTBOX
WHERE ACCOUNT_NUMBER = ME!ACCOUNT_NUMBER"

It fails if user uses a single quote, since the SQL server assumes it is the
end of SQL statement.

Will it work if user uses double quote?
Any information is great appreicated,
 
D

Douglas J. Steele

"INSERT INTO MYTABLE
SET COMMENTS = '" & Replace(ME!MYLISTBOX, "'", "''") &
"' WHERE ACCOUNT_NUMBER = " & ME!ACCOUNT_NUMBER

Exagerated for clarity, the second line is

SET COMMENTS = ' " & Replace(ME!MYLISTBOX, " ' ", " ' ' ") &

and the third line starts:

" ' WHERE ...
 
Top