Copy a Table's Structure but not data records

M

Mark

I would like to copy a table's structure but not the
records.

The following code copies both structure and records:
DoCmd.CopyObject, TableCopy, acTable, TableOrig

Then I loop through the Copied Table and delete its
records.

I would like to avoid the record deletion business if
possible.

Thanks
Mark
 
G

Gerald Stanley

Have you looked at DoCmd.TransferDatabase

Hope This Helps
Gerald Stanley MCSD
 
D

Dirk Goldgar

Mark said:
I would like to copy a table's structure but not the
records.

The following code copies both structure and records:
DoCmd.CopyObject, TableCopy, acTable, TableOrig

Then I loop through the Copied Table and delete its
records.

I would like to avoid the record deletion business if
possible.

Thanks
Mark

For example,

' Copy structure of Table1 to new table, Table1_Copy.

DoCmd.TransferDatabase _
acExport, _
"Microsoft Access", _
CurrentDb.Name, _
acTable, _
"Table1", _
"Table1_Copy", _
True
 
D

Duane Hookom

I'm not sure why you would "loop through" anything. A simple query like:
DoCmd.RunSQL "Delete * from tblNewTable"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top