Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strip quotation marks from text field?? 1

Status
Not open for further replies.

lachesis

Technical User
Sep 25, 2002
138
NZ
I have an unbound text field on my Call Log form that records text into a Memo field in tbl_Call.

Trouble is when the INSERT INTO SQL string is built up in VBA code I get errors running this statement, if the Memo field contains any quotation marks, doubles("") or singles('').

How do the pros work around this one? Is there a quick means of parsing the Memo field, and stripping out any "incidental" quote marks before adding it into the SQL string??

cheers
L.
 
Try using the ' - located next to the enter key, also carries the sign *.



Herman

They say that crime doesn't pay... does that mean my job is a crime?
 
Hi lachesis,

I think you know what the problem is, so just a brief overview before the answer.

You are trying to build a string in VBA, which will be interpreted as a literal by Jet later and so any quote characters within it which match the bounding quote character must be doubled up. If you have VBA 6 (Access 2K) or later, you can use the Replace Function ..

Code:
"INSERT .... '" & Replace(
Code:
TextboxValue
Code:
,"'","''") & "'" & ...

If you don't have Replace, you need to write your own function to do the same. More than one has been posted here before so if you need help with that try a search, and if that fails come back and I'll provide one or find a reference for you.

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
Thanks Tony. That got me onto the right track.

L.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top