Creating a blank copy of a database in code

  • Thread starter Thread starter vw
  • Start date Start date
V

vw

Does anyone know how to, in code, create a copy of an
existing Microsoft Access database? I know how to do same
using MSA's menus but I want to automate to process to
copy the existing database including tables but I'd like
to only copy the structure of the tables.

Any help would be greatly appreciated.

vw
 
Take a look in Access VBA Help at CopyObject and TransferDatabase. You'll
also, of course, need to look at Containers and Collections in order to
determine what objects are in the database to be exported.

Larry Linson
Microsoft Access MVP
 
Thanks for replying Larry,

I've done this and have a routine to create a copy using
the methods you described. I even found a routine to do
the same after I had finished my own. But, what I would
really like to be able to do next is to create a copy that
has no data in the copy's tables. I'm pretty sure that I
can set a reference to the copy and run some delete
queries to do delete the tables - just wondering if there
is a better or quicker way in code.

What I would love to do is something in code to automate
what I can do manually using File>Get External
Data>Import. With the Import Objects window I can import
all database objects and there is a radio button group
under Options that allows you to select either 'Definition
and Data' or 'Definition Only'. I don't need to display
this or any other options, I would just like to be able to
import the table structure without the existing data.

I don't know if that explanation was any clearer than my
first post but I do appreciate your taking the time to
respond.

Thanks again,
vw
 
Thanks for replying Larry,

I've done this and have a routine
to create a copy using the methods
you described. . . . I would just
like to be able to import the table
structure without the existing data.

TransferDatabase has a StructureOnly argument that should do what you want.

Larry Linson
Microsoft Access MVP
 
Thank you Larry. I did not realize that argument was
there. That should allow me to do what I want.
 
Back
Top