Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Access DoCmd.Transferdatabase Assistance

DarkOne72

Technical User
Jun 14, 2002
210
US
Hi All,

I am trying to copy/transfer tables from one database to another BUT doing it from a master database. For example, the Master database has a button that when clicked will copy/transfer tables from database-A to database-B (so 3 databases in total)
I have searched for awhile and cannot find any way to do it so I thought maybe to copy/transfer the tables from database-A to the Master temporarily and then use the docmd.transferdatabase acExport to database-B.

I tried the below to import it to the master database, btw the strdatabase-A is the reference to the path to where the database is stored

Code:
DoCmd.Transferdatabase  acImport , "Microsoft Access", acTable , strdatabase-A, acTable, "tblContacts", "tblContacts" , False

Any help would be appreciated.
Thank you
 
Last edited:
I have figured it out by importing the table from database-A into the Master DB and then exporting it to database-B and then deleting the table out of the master db.
If anyone is interested here is the code as I used as an example

Code:
DoCmd.TransferDatabase acImport, "Microsoft Access", strdatabase-A, acTable, "tblContacts", "tblContacts", False
DoCmd.TransferDatabase acExport, "Microsoft Access", strdatabase-B, acTable, "tblContacts", "tblContacts", False
DoCmd.DeleteObject acTable, "tblContacts"

Thank you for looking.
 
Docmd belongs to the application object model so in order to use it, you need the database open in the application or do as you did round trip it through the current session.

In short to do it more directly you would need to automate Access from within Access.

In the back of my mind is OpenCurrentDatabase that is needed for opening a database for automation. Probably a method. - Sometimes I squirrel away a key piece so I can look up later without digging too much.

Your method will work and probably not too bad for smaller tables. However it may be more than worth the time to open the database to transfer a larger table.
 

Part and Inventory Search

Sponsor

Back
Top