[AccessD] Text problem in runSQL

Stuart McLachlan stuart at lexacorp.com.pg
Thu Apr 16 23:39:32 CDT 2009


As an alternative to Arthur's quoting functions, you can escape the single quotes by 
replacing a single quote with two single quotes before putting it into the SQL string

i.e.   txt = Replace(txt,"'","''")

To make it a bit clearer, here it is again with a lot of extra spaces inserted:
txt = Replace(txt, "  '  " , "  '  '  " )  

-- 
Stuart

On 16 Apr 2009 at 23:02, Annie Courchesne, CMA wrote:

> Now here's the problem : If the text has a ' in it (exemple : Stone wall of
> 20' x 10'),  I try to run add "White" in front of the text, it does not
> work.  Here the code I use :
> 
> 
> Dim txt as string
> 
> Txt=me.word & " " & me.description
> 
> SQL = "UPDATE tblSoumissionDetail SET tblSoumissionDetail.Description = '" &
> txt & "' WHERE (((tblSoumissionDetail.SoumDetailID)=" & Me.Parent.LigneID &
> "));"
> 
> DoCmd.RunSQL SQL
> 




More information about the AccessD mailing list