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!

How to duplicate a table in access

Status
Not open for further replies.
Dec 23, 2004
33
US
I would like to duplicate Table1 using the similar code below:

StDocName1 = "Table1"
StDocName2 = "New Table"

DoCmd.Rename StDocName2, acTable, StDocName1

Thanks.
 
You say "duplicate" (as in creating a new table) but reference the "rename" command, so I'm not sure what you want.

This should make a copy of a table .......

strsql = "select * into tblCopy from tblExisting"
Docmd.RunSQL(strsql)

 
DoCmd.CopyObject, StDocName2, acTable, StDocName1

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi,

DoCmd.CopyObject, StDocName2, acTable, StDocName1

I used this code but it did not work for me because I did not have the comma (,) between the CopyObject and StDocName2. Why don't we need the comma for the rename command?

DoCmd.Rename StDocName2, acTable, StDocName1

Again, thanks for your help.

 
Cogivina2004,

Some hints, enter VBE and lookup the two methods in the help file (hit F1 while the cursor is within the method name). You'll find they have a different number of arguements.

And, for Access related questions, why not visit some of the Access fora (there's seven of them). Do a forum search (top of the page) to find them.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top