Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reproduce table structure? 1

Status
Not open for further replies.

WaltW

MIS
Jun 14, 2000
130
US
In one click event on one of my forms, I need to be able to create a new table, then exactly duplicate the structure (not the data) of an already-existing table in the new table. What's the simplest and quickest way to do this in VBA? The only thing I've been able to come up with so far is to reproduce each field one at a time - is there a way to reproduce the entire structure at once?

WaltW
 
You can copy the entire table (CopyObject Method) and do a delete * query on the new database. There are other vialble approaches. However, this works well for tables which do not have a lot of records. (If there are a LOT of records, the copy and delete processes take to much time).



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
I'm about to do this very thing in a project. Use the TransferDatabase method of the DoCmd object, setting the structureonly parameter to True. That will copy the entire structure of your source table into a new table you specify, even in a different database if you wish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top