[AccessD] Text problem in runSQL

Stuart McLachlan stuart at lexacorp.com.pg
Fri Apr 17 05:46:11 CDT 2009


You can "escape"  both single and double quotes.
.....
txt = replace(txt,"'","''")
txt = replace(txt,""","""")
SQL = ........ & txt & ......
....

-- 
Stuart


On 17 Apr 2009 at 6:25, Annie Courchesne, CMA wrote:

> Rocky,
> 
> Thanks for the info... however, yes I can have " and ' because my customer
> can quote in inch an in feet.  I'll try to see if it works if instead of
> using " my customer user '' to represent the inches.
> 
> 
> Annie
> 
> -----Message d'origine-----
> De : accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] De la part de Rocky Smolin
> Envoyé : 17 avril 2009 01:21
> À : 'Access Developers discussion and problem solving'
> Objet : Re: [AccessD] Text problem in runSQL
> 
> Annie"
> 
> If you have apostrophes in your text then instead of using apostrophes to
> delimit the string use double quotes - "".
> 
> So tblSoumissionDetail.Description = '" & txt & "'
> 
> Becomes tblSoumissionDetail.Description = """ & txt & """
> 
> Of course, if you then encounter a string with quotes in it, like
> representing inches, you've got the opposite problem.
> 
> Rocky
> 
> 
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Annie Courchesne,
> CMA
> Sent: Thursday, April 16, 2009 8:03 PM
> To: Accessd
> Subject: [AccessD] Text problem in runSQL
> 
> Hi everyone,
> 
>  
> 
> I'm having a problem with a function that a customer wants.  It's for making
> quotation.  I have a subform that has the lines of the quote.  On another
> subform, I have a list of words.  When I double click on the word, it adds
> it wherever the pointer was in the lines of the quotes.  So far, no problem
> with that.  
> 
>  
> 
> 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
> 
>  
> 
>  
> 
>  
> 
> Me.word : White
> 
> Me.description : Stone wall of 20' x 10'
> 
>  
> 
> In an exemple as this one, I get a runtime error 3075.  I know it's because
> of the ' . but I have no idea how to solve this!
> 
>  
> 
> Anyone can help?
> 
>  
> 
> Thanks!
> 
>  
> 
>  
> 
> Annie
> 
>  
> 
>  
> 
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 






More information about the AccessD mailing list