Link to home
Start Free TrialLog in
Avatar of generali
generali

asked on

VBA/Access hanling apostrophe (')?

I am opening some data in a recordset and that looping through the data and running a simpe update query using docmd.runsql...my problem arises when I come accross a name that has an apostrophe in it i.e. O'Hara, then I receive a run time error. Does anybody know of a way to handle this?
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Instead of using the field directly use:
Replace(fieldname, "'", "''")
which replaces a single quote with two.
Avatar of generali
generali

ASKER

capricorn1-

tried the first one and returned - '" & Nz(rst!Debtor, ") & "' in my sql but replaced the double single quote with space and worked a treat.

Many Thanks