ishaqani
03-29-2007, 09:52 PM
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
neileg
03-30-2007, 12:18 AM
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?
ishaqani
03-30-2007, 12:40 AM
It is neccesary, I have to transfere some tables to xyz.mdb file.
boblarson
03-30-2007, 03:40 AM
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.
boblarson
03-30-2007, 03:44 AM
Oops!
Got the close in the wrong place:
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