S
steve
I mostly use macros because my knowledge in vba / sql is very small.
I need to remove the primary key from one field and put it on another.
After picking around on the net I cobbled the following code together
that adds the key to the right field. However this only will add the
key if there is no key already in the table. The table im trying to
change the key on already has one. Can someone show me how to remove
the key first so that I can then run the below code to add it to the
right field. I have found several examples on the net but I cant seem
to get it to work properly.
strSql = "ALTER TABLE [tmptblStructureOnlytblLogfile] " & _
"ADD Constraint PK_tmpTblStructureonlytblLogfile PRIMARY KEY
(ComputerName)"
CurrentDb.Execute strSql, dbFailOnError
Thanks.
I need to remove the primary key from one field and put it on another.
After picking around on the net I cobbled the following code together
that adds the key to the right field. However this only will add the
key if there is no key already in the table. The table im trying to
change the key on already has one. Can someone show me how to remove
the key first so that I can then run the below code to add it to the
right field. I have found several examples on the net but I cant seem
to get it to work properly.
strSql = "ALTER TABLE [tmptblStructureOnlytblLogfile] " & _
"ADD Constraint PK_tmpTblStructureonlytblLogfile PRIMARY KEY
(ComputerName)"
CurrentDb.Execute strSql, dbFailOnError
Thanks.