VBA and SQL

Jishnu Surendran

New Member
Joined
Jul 29, 2013
Messages
32
I have to insert some data into an .mdb file from an excel worksheet. The ADO connection was created successfully. The 'insert into' query has to be combined with 'where not exists' to avoid inserting duplicate data. I have to select some data from a worksheet of the active workbook (say 'c') to query the 'where not exists' part. Tried the following:
Insert into................Select * From ([c]) Where Not Exists (.......).
I am getting a 'syntax error for from clause' error. Any help on how to select the data from a sheet of current workbook using sql.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Can you give us more information? Impossible to help with such little information
IF C is the worksheet not workbook and the column names come after Email, Name etc.
SELECT [C$].Email, [C$].Name FROM [C$] WHERE ...
 
Upvote 0
Can you give us more information? Impossible to help with such little information
IF C is the worksheet not workbook and the column names come after Email, Name etc.
SELECT [C$].Email, [C$].Name FROM [C$] WHERE ...
Hi, You've made it simple for me. Taking your example, this query 'SELECT [C$].Email, [C$].Name FROM [C$] WHERE ...' when I am doing it generates a 'syntax error From clause'. Is it possible to select from the worksheet just like 'SELECT [C$].Something'?
 
Upvote 0

Forum statistics

Threads
1,216,591
Messages
6,131,622
Members
449,658
Latest member
JasonEncon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top