importing fields from 1 DB to another DB

J

JT

I am trying to import 4 fields from database1 into a table in database2.
Here is the code I am using:

vSQL = "INSERT INTO CITY_TABLE SELECT [Field1],[Field2],[Field3],[Field4]
FROM [All_Officesl] IN 'C:\Locations\City.mdb' WHERE [Field1] = '" & Loc & "'"

Set Recordset = New ADODB.Recordset
Call Recordset.Open(vSQL, ConnectionString, adOpenForwardOnly,
adLockReadOnly, CommandTypeEnum.adCmdText)

Set Recordset = Nothing

City_Table is the table in database2

Loc is a variable that identifies which retail location this is getting

ConnectionString is a variable that is the same as the IN statement
('C:\Locations\City.mdb' )

I keep getting an error message that says the Output table cannot be located.

What am I doing wrong....Thanks for the help.
 
V

Van T. Dinh

Why are you using Open Recordset for an INSERT SQL???

Shouldn't it be Connection.Execute?

Check Access / VB Help / AD on Execute method.
 

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