find system-gen'd constraint name..

  • Thread starter Thread starter Guest
  • Start date Start date
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!
 
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
 
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
 
Back
Top