Public Function mdbdIsPK(tdf As DAO.TableDef, fld As DAO.Field) As Boolean
'MDBDOC: Returns True/False depending whether a specific field is part of a specific tables primary key.
' Function: mdbdIsPK
' Parameters: tdf - Tabledef; fld Field
' Return Value: Boolean - True if fld is in primary key of table tdf, false otherwise
' Author: John Barnett
' Date: 10 July 2001.
' Description: IsPK returns a True/False value depending whether field fld is part of the primary key of table pk.
' Called by: Fields section of ProcessDatabase
Dim idx As Index
mdbdIsPK = False
For Each idx In tdf.Indexes
' Loop through each of the table indexes
If InStr(idx.Fields, fld.Name) Then
' if the field name is in the index and the index is the primary one then it is true
If idx.Primary = True Then
mdbdIsPK = True
Exit For
End If
End If
Next idx
End Function