Create new database on command from existing database

D

DarS

I have a table in an existing database that I would like to export to a new
database using an event procedure or macro. I would like to name the new
database with the date it is created. Any suggestions?
 
A

Allen Browne

You can create the database like this:
Dim ws As DAO.Workspace
Dim dbBackup As DAO.Database
Dim strFile As String
strFile = "C:\" & Format(Date, "yyyymmnn") & ".mdb"
Set dbBackup = ws.CreateDatabase(strFile, dbLangGeneral)

You can then execute an Append query statement to add the table to the
database. Create a query using the table you want to export. Change it to an
Append query (Append on Query menu). Access gives you a dialog where you can
specify the name of the external file to export to.
 
D

DarS

Thank you!
--
Dar


Allen Browne said:
You can create the database like this:
Dim ws As DAO.Workspace
Dim dbBackup As DAO.Database
Dim strFile As String
strFile = "C:\" & Format(Date, "yyyymmnn") & ".mdb"
Set dbBackup = ws.CreateDatabase(strFile, dbLangGeneral)

You can then execute an Append query statement to add the table to the
database. Create a query using the table you want to export. Change it to an
Append query (Append on Query menu). Access gives you a dialog where you can
specify the name of the external file to export to.
 
Top