Extracting data from Access

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
Can you post your entire SQL code. Seems like you should just replace
all the Foster's examples without the ' s.

Stopher
 
Back
Top