Trouble inputting Aposrophe.

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?
 
A

Allen Browne

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.
 

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