Trouble inputting Aposrophe.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a main form for customer head office details with CustID, CustName,
CustAddress etc which has a subform for invoice addesses. There is also a
command button which will take you to another form which is for delivery
addresses. Now some customers have an apostrophe in their company names but
if I put the apostrophe in the text box containing the company name, say
“Acme’s†for instance, and then click the delivery address command button I
get an error message saying “Syntax error in string in query expression
’[CompanyName]=’Acme’sâ€. I can put any other puctuation in and it opens the
delivery address form no problem. What am I doing wrong and is there any way
to cure it?
 
Use the double-quote instead of the single quote to delimit the value, i.e.:
"[CompanyName=""Acme's"""

The doubled-up double quotes are needed to tell VBA this is an embedded
quote, not the end of the string.
 
Back
Top