Copy a Table's Structure but not data records

  • Thread starter Thread starter Mark
  • Start date Start date
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
 
Have you looked at DoCmd.TransferDatabase

Hope This Helps
Gerald Stanley MCSD
 
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
 
I'm not sure why you would "loop through" anything. A simple query like:
DoCmd.RunSQL "Delete * from tblNewTable"
 
Back
Top