Text in SQL Statement

M

magmike

I have a command on a form, that transfers values into other fields.

Code:
SQL = "Insert into Contacts ( ContactCompany, ContactFirstName,
ContactLastName, ContactTitle, ContactAddress1, ContactAddress2,
ContactCity, ContactState, ContactZip, ContactDirectPhone, ContactFax,
ContactGender)" & _
"SELECT Forms!ProspectForm!ID,FirstName,LastName,TitleCode,Forms!
ProspectForm!Address,Forms!ProspectForm!Address2,Forms!ProspectForm!
City,Forms!ProspectForm!State,Forms!ProspectForm!ZipCode,Forms!
ProspectForm!Phone,Forms!ProspectForm!Fax,Gender"

I want to add the value, "Source: Dunn and Bradstreet" to the
ContactNotes field. Because of the quotation marks, however, I am
having trouble. What am I doing wrong?

What I tried:
SQL = "Insert into Contacts ( ContactCompany, ContactFirstName,
ContactLastName, ContactTitle, ContactAddress1, ContactAddress2,
ContactCity, ContactState, ContactZip, ContactDirectPhone, ContactFax,
ContactGender, ContactNotes)" & _
"SELECT Forms!ProspectForm!ID,FirstName,LastName,TitleCode,Forms!
ProspectForm!Address,Forms!ProspectForm!Address2,Forms!ProspectForm!
City,Forms!ProspectForm!State,Forms!ProspectForm!ZipCode,Forms!
ProspectForm!Phone,Forms!ProspectForm!Fax,Gender,'"Source: RefUSA"'"
 
K

Ken Sheridan

A pair of contiguous double quotes characters within a string expression is
interpreted as a single double quotes character:

"….. Forms!ProspectForm!Fax,Gender,""Source: Dunn and Bradstreet"""

Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top