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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I set a Primary Key on a Make Table SQL Statement

Status
Not open for further replies.

ChaseMIS

MIS
Jul 31, 2001
23
US
The subject of this message sums up what I am trying to do. In the interest of making a process foolproof, a previous programmer designed the process so that each run deletes the necessary table and then recreates it using a make table query written in the code. The idea behind this was to render any multiple runs of the process harmless. Recently, we have started to see duplicate data and this is causing real problems. One of the fields in the table is a unique identifier and could be used a the primary key but I don't know how to include that in the SQL statement. The help file has been less than helpful. Any assistance would be greatly appreciated.

Thanks,
Derek
 
I'm not going to do all the work for you but here is a small example: you can look up CREATE UNIQUE INDEX



DoCmd.OpenQuery "MyQuery"
db.Execute "CREATE UNIQUE INDEX MyIndexName " _
& "ON MyTableName(FieldName) " _
& "WITH DISALLOW NULL;"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top