Populating A Code Created Database

  • Thread starter Thread starter Andy
  • Start date Start date
A

Andy

I have used CreateDatabase to make an empty database but
now want to populate it using code with a copy of some
objects (table, form etc.) from an existing master
database. Any suggestions as to the best way ?
 
Andy said:
I have used CreateDatabase to make an empty database but
now want to populate it using code with a copy of some
objects (table, form etc.) from an existing master
database. Any suggestions as to the best way ?

Assuming you don't want to just copy the master to a new file and then
open that new file and customize it, the approach you take depends on
whether the master database is the one in which your code is running or
not. If your code is running in the master database, you can easily use
DoCmd.TransferDatabase or DoCmd.CopyObject to copy objects from that
database to the new one you created. If not, you can open a second
instance of Access and use automation in that instance to open the new
database file, then import objects from the master database using
DoCmd.TransferDatabase.
 
-----Original Message-----


Assuming you don't want to just copy the master to a new file and then
open that new file and customize it, the approach you take depends on
whether the master database is the one in which your code is running or
not. If your code is running in the master database, you can easily use
DoCmd.TransferDatabase or DoCmd.CopyObject to copy objects from that
database to the new one you created. If not, you can open a second
instance of Access and use automation in that instance to open the new
database file, then import objects from the master database using
DoCmd.TransferDatabase.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
Thanks for your help Dirk. Working from the master
database I used DoCmd.CopyObject to copy out a table,
query, macro and form and it did exactly what I wanted!
 
Back
Top