Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with single quote in recordset field of UPDATE query 1

Status
Not open for further replies.

rss0213

Programmer
Jul 12, 2007
58
US
I have this code to update an Access table from a text file (this is actually vb script):

sqlStr = "UPDATE CustomersMain SET [RMName] = '" & trim(oRS("OfficerName")) & "' WHERE [CustomerID] = " & trim(oRS("CustomerId"))

Problem I have is when an OfficerName has a single quote in it, like O'BRIEN. how do I handle this?

Thanks!
Scott
 

Try:
Code:
sqlStr = "UPDATE CustomersMain SET [RMName] = '" & [blue]Replace[/blue](trim(oRS("OfficerName"))[blue], "'", "''")[/blue] & "' WHERE [CustomerID] = " &  trim(oRS("CustomerId"))

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top