Copy Object Table with Primary Key

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
 
G

Guest

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.
 
G

Guest

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.
 

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