Exporting Tables to New MDB File

ishaqani

Registered User.
Local time
Today, 14:36
Joined
Mar 4, 2007
Messages
13
I want to export my tables to another new mdb file using only one click button command. Means when i click export button, prompt me to create new mdb file and then immediatly transfer to required tables in newly created mdb file and confirm or completed msg box appear.

Can any one help me in this regard or give me a code or anything.

Thanks
 
Can I ask why you want to do this? Is it not prefereable to link your second database to the first so that there's no need to export the data?
 
It is neccesary, I have to transfere some tables to xyz.mdb file.
 
Code:
Dim AccApp As Access.Application

Set AccApp = New Access.Application

AccApp.NewCurrentDatabase "YourFilePathHere"
AccApp.Visible = True

DoCmd.TransferDatabase acExport, "Microsoft Access", "YourPathAndNameOfNewDatabase", acTable, "YourTableNameHere", "TheNewTableNameHere", False
...Put more DoCmd.TransferDatabase lines here for each table you want exported.
AccApp.CloseCurrentDatabase

Set AccApp = Nothing
The part where it says False in the DoCmd line is saying transfer structure only, no put the data there too. If you want to only transfer the structure put True instead.
 
Oops!

Got the close in the wrong place:

Code:
Dim AccApp As Access.Application

Set AccApp = New Access.Application

AccApp.NewCurrentDatabase "YourFilePathHere"
AccApp.Visible = False

AccApp.CloseCurrentDatabase

DoCmd.TransferDatabase acExport, "Microsoft Access", "YourPathAndNameOfNewDatabase", acTable, "YourTableNameHere", "TheNewTableNameHere", False
...Put more DoCmd.TransferDatabase lines here for each table you want exported.

Set AccApp = Nothing
 

Users who are viewing this thread

Back
Top Bottom