Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Single and Double Quotes


Message #1 by "Enzo Zaragoza" <enzaux@g...> on Thu, 12 Dec 2002 11:42:32 +0800
	Hello!  I'm wondering how would I save a text data having a single or
double quote? I'm using unbound forms so I do the saving manually.

If I use this one I could not save text data with single quote:
strSQL = "UPDATE Table1 Set strName='" & Text1.Text & "' WHERE lngUserID=" & Text1.Text

If I use this one I could not save text data with double quote:
strSQL = "UPDATE Table1 Set strName=""" & Text1.Text & """ WHERE lngUserID=" & Text1.Text

	Any tips?

Thanks,

enzo c",)?


Message #2 by "Haslett, Andrew" <andrew.haslett@i...> on Thu, 12 Dec 2002 15:38:01 +1030
Would a mixture work? 

.... strName = '"" & text & ""' WHERE .......

Or use your first example but replace single quotes with two singles, so:
... SET strName = '" & replace(text1.text, "'", "''") & "' WHERE......

But then you'll have to remember to change them back again when outputting.

-----Original Message-----
From: Enzo Zaragoza [mailto:enzaux@g...]
Sent: Thursday, 12 December 2002 2:13 PM
To: Access
Subject: [access] Single and Double Quotes



	Hello!  I'm wondering how would I save a text data having a single
or
double quote? I'm using unbound forms so I do the saving manually.

If I use this one I could not save text data with single quote:
strSQL = "UPDATE Table1 Set strName='" & Text1.Text & "' WHERE lngUserID=" &
Text1.Text

If I use this one I could not save text data with double quote:
strSQL = "UPDATE Table1 Set strName=""" & Text1.Text & """ WHERE lngUserID="
& Text1.Text

	Any tips?

Thanks,

enzo c",)(tm)




IMPORTANT - PLEASE READ ******************** 
This email and any files transmitted with it are confidential and may 
contain information protected by law from disclosure. 
If you have received this message in error, please notify the sender 
immediately and delete this email from your system. 
No warranty is given that this email or files, if attached to this 
email, are free from computer viruses or other defects. They 
are provided on the basis the user assumes all responsibility for 
loss, damage or consequence resulting directly or indirectly from 
their use, whether caused by the negligence of the sender or not.
Message #3 by "Brian Skelton" <brian.skelton@b...> on Thu, 12 Dec 2002 08:49:20 -0000
Hi Enzo

Use the Replace function:

strSQL =3D "UPDATE Table1 Set strName=3D'" & 
Replace(Text1.Text,"'","''") &
"' WHERE lngUserID=3D" & Text1.Text

Brian

-----Original Message-----
From: Enzo Zaragoza [mailto:enzaux@g...]
Sent: 12 December 2002 03:43
To: Access
Subject: [access] Single and Double Quotes


	Hello!  I'm wondering how would I save a text data having a
single or
double quote? I'm using unbound forms so I do the saving manually.

If I use this one I could not save text data with single quote:
strSQL =3D "UPDATE Table1 Set strName=3D'" & Text1.Text & "' WHERE
lngUserID=3D" & Text1.Text

If I use this one I could not save text data with double quote:
strSQL =3D "UPDATE Table1 Set strName=3D""" & Text1.Text & """ WHERE
lngUserID=3D" & Text1.Text

	Any tips?

Thanks,

enzo c",)=99





  Return to Index