View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Daniel Bonallack Daniel Bonallack is offline
external usenet poster
 
Posts: 110
Default Extracting data from Access

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