LOST you suggestion to escape erro with apostroph in insert

User avatar
sal21
PlatinumLounger
Posts: 4363
Joined: 26 Apr 2010, 17:36

LOST you suggestion to escape erro with apostroph in insert

Post by sal21 »

Sorry me Hans, but changed my pd and lost all youy preciuos suggestion! :grin: :scratch:

How to inser or update recordset where the value in question have apostroph?...

i remember only to replace a var with:

my_var=replcae(my_var,???????????)

example my_var="d'amico"

tks as usual.

User avatar
HansV
Administrator
Posts: 78547
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: LOST you suggestion to escape erro with apostroph in ins

Post by HansV »

Depends on how you're going to use it.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4363
Joined: 26 Apr 2010, 17:36

Re: LOST you suggestion to escape erro with apostroph in ins

Post by sal21 »

HansV wrote:Depends on how you're going to use it.
Here si a difference in insert or update query?

User avatar
HansV
Administrator
Posts: 78547
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: LOST you suggestion to escape erro with apostroph in ins

Post by HansV »

If you create an SQL string in VBA with apostrophes / single quotes around text values, you need to replace apostrophes within those text values with two apostrophes:

Code: Select all

my_var=replace(my_var,"'", "''")
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4363
Joined: 26 Apr 2010, 17:36

Re: LOST you suggestion to escape erro with apostroph in ins

Post by sal21 »

HansV wrote:If you create an SQL string in VBA with apostrophes / single quotes around text values, you need to replace apostrophes within those text values with two apostrophes:

Code: Select all

my_var=replace(my_var,"'", "''")
Sorry to reply in old post...
but,

now have my_var=valle d'aosta
I use the tips in question when i see the record in field i have:
valle d''aosta.!!!!!!!!!!!!!!!

note:
Ths field is in txt format
Last edited by sal21 on 17 Jan 2011, 15:16, edited 2 times in total.

User avatar
HansV
Administrator
Posts: 78547
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: LOST you suggestion to escape erro with apostroph in ins

Post by HansV »

Please post the SQL you're using.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4363
Joined: 26 Apr 2010, 17:36

Re: LOST you suggestion to escape erro with apostroph in ins

Post by sal21 »

HansV wrote:Please post the SQL you're using.
resolved my self.. tks in other case.