Copy Object Table with Primary Key

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anyone know how to make a copy of a table with a primary key(Temp1).
I've use the following code and this does not copy the primary key to the new
table(Temp2).

DoCmd.CopyObject "Temp2", acTable, "Temp1"

Thank you,

Sarah
 
You might try the CreateIndex method, or you can use Jet SQL DDL. Here is an
example:
currentdb.Execute("CREATE INDEX FUZZ ON tblStuff(Stuff) WITH
PRIMARY;"),dbfailonerror

Creates an index named FUZZ on the field named Stuff in the table tblStuff
and makes it the primary key.
 
I've tried that and it works, but not with my code. I have problems creating
an index which is the primary key. Therefore I wanted another way of doing
this by just making a copy of a table that has a primary key.

Thanks anyway.
 
Back
Top