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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
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,223,888
Messages
6,175,213
Members
452,618
Latest member
Tam84

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