Extracting data from Access

G

Guest

I am having problems with apostrophes...

I'm in Excel, and using Excel VBA, I utilize an ADODB connection to get data
out of Access

The user enters a company name (eg, General Motors), and all the deals for
General Motors are returned.

The simplified line of SQL is:
HAVING (((Deals.Company)="General Motors"));

But in Excel VBA, the quotations are changed for apostrophes
HAVING (((Deals.Company)='General Motors'));

And I use a variable, rather than the company name
[Earlier]
myCompany= InputBox("What company?")
[Later]
HAVING (((Deals.Company)="'" & myParent & "'"));

This works for 99% of my companies, but not for companies with an apostrophe
in it. eg "Foster's Group". For this company, I get an error when I come to
extract the data.

Can anyone advise me how to handle this variation?

Thanks
Daniel
 
S

Stopher

Can you post your entire SQL code. Seems like you should just replace
all the Foster's examples without the ' s.

Stopher
 

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