find system-gen'd constraint name..

G

Guest

how would one find out a system generated constraint name for primary key to
drop it?

i'm trying to expand the primary key (to multi-field) on a table, so
thinking i'd drop index and constraint, then create new indexes and constaint
-

thanks!
 
D

Douglas J. Steele

Using DAO, you can loop through all of the indexes for the table, looking
for the one whose Primary property is set to True.

Dim dbCurr As DAO.Database
Dim tdfCurr As DAO.TableDef
Dim idxCurr As DAO.Index

Set dbCurr = CurrentDb()
Set tdfCurr = dbCurr.TableDefs("NameOfTable")
For Each idxCurr In tdfCurr.Indexes
If idxCurr.Primary = True Then
Debug.Print idxCurr.Name & " is the Primary Key of the table."
Exit For
End If
Next idxCurr
 
G

Guest

Thanks Doug - got it!

Douglas J. Steele said:
Using DAO, you can loop through all of the indexes for the table, looking
for the one whose Primary property is set to True.

Dim dbCurr As DAO.Database
Dim tdfCurr As DAO.TableDef
Dim idxCurr As DAO.Index

Set dbCurr = CurrentDb()
Set tdfCurr = dbCurr.TableDefs("NameOfTable")
For Each idxCurr In tdfCurr.Indexes
If idxCurr.Primary = True Then
Debug.Print idxCurr.Name & " is the Primary Key of the table."
Exit For
End If
Next idxCurr
 

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