How to copy tables in db1 to db2 from code in db3

A

Alp

Hi Experts,

I think this had been addressed before but just refuses to show up in my
searches:

How can I copy a (a few) table via code between two external databases? I do
not want to import and then export/copy if possible.

Thanks in advance.

Alp
 
M

Matthias Klaey

Hi Experts,

I think this had been addressed before but just refuses to show up in my
searches:

How can I copy a (a few) table via code between two external databases? I do
not want to import and then export/copy if possible.

Thanks in advance.

Alp

In db3, the code should look something like this:

Dim db1 As DAO.Database
Dim qdf As DAO.QueryDef

Set db1 = DBEngine.OpenDatabase("<pat>\db1.mdb")
Set qdf = db1.CreateQueryDef("", "Insert Into table 2 " & _
" In '<path>\db3.mdb' " & _
" Select * From table1;"
qdf.Execute dbFailOnError
qdf.close
Set qdf = Nothing
db1.Close
Set db1 = Nothing

For details on Insert...Into and Select...Into (Make Table Query), see
the Online Help.

HTH

Matthias Kläy
 
A

Alp

Hi Matthias,

Thank you for your response. Besides what I have done to resolve it, I will
also try your suggestion. Wish you a happy new year.

Alp
 

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