The primary key is usually named PrimaryKey, but it doesn't have to be. If
you don't know the name of the key, you could loop through all of the
indexes in the Indexes collection, looking for the one that has its Primary
property set to True, something like in the following untested air-code:
Sub DeletePrimaryKey(TableName As String)
Dim indCurr As DAO.Index
For Each indCurr In CurrentDb().TableDefs(TableName).Indexes
If indCurr.Primary = True Then
CurrentDb().TableDefs(TableName).Indexes.Delete indCurr.Name
Exit For
End If
Next indCurr
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.