Trouble creating SQL statement from MS Access Form

5 pts.
Tags:
Microsoft Access
Microsoft Access 2007
Microsoft Windows Vista
SQL
VBA
I'm creating an INSERT statement from the text fields in a form. This is a snippet:

mySQL = mySQL & Combo0 & "','" & Text3 & "','" & Text5 & "','" & Text7


I am alternating the double and single quotation marks to enclose the entire statement as a single STRING while using the single quotation marks for the individual text fields. However, these fields are names and addresses and if there is anything like "O'Brien" or "Marc's" then the entire statement fails because of the extra quotation mark. I've tried using "Chr(34)" but once they are in a STRING that's how they stay. Any help would be appreciated



Software/Hardware used:
MS Access 2007, Windows Vista

Answer Wiki

Thanks. We'll let you know when a new response is added.

I found this bit of code:
Dim escapedString as String

escapedString = Replace(nonescapedString, "'", "''")

Basically you need to replace the text field’s single-quote to double single-quotes (similar to how in MySQL you need to do ‘ for single quotes.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following