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

  • Thread starter Thread starter Alp
  • Start date Start date
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
 
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
 
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
 
Back
Top