GPGeorge
George Hepworth
- Local time
- Today, 11:26
- Joined
- Nov 25, 2004
- Messages
- 3,301
It's HIDDEN. That's why your screenshot of the Index property sheet does not show it. That is, in fact, the whole basis of this entire discussion.
Access creates an index, automatically, on fields defined as Foreign Keys. These indexes do not appear in the Index Property Sheet. I.e. "hidden".
Pat provided VBA to reveal it. See her screenshot of the Analyzer report, as well.
Run this, please, on your sample accdb.
Access creates an index, automatically, on fields defined as Foreign Keys. These indexes do not appear in the Index Property Sheet. I.e. "hidden".
Pat provided VBA to reveal it. See her screenshot of the Analyzer report, as well.
Run this, please, on your sample accdb.
Code:
Public Sub ListIndexes()
Const adSchemaIndexes As Long = 12
Dim cn As Object ' ADODB.Connection
Dim rs As Object ' ADODB.Recordset
Dim i As Long
Set cn = CurrentProject.Connection
Set rs = cn.OpenSchema(adSchemaIndexes, Array(Empty, Empty, Empty, Empty, "tblBloodPressure"))
With rs
' enable next three lines to view all the recordset column names
' For i = 0 To (.Fields.Count - 1)
' Debug.Print .Fields(i).Name
' Next i
Do While Not .EOF
Debug.Print !TABLE_NAME, !INDEX_NAME, "Is Primary Key " & !PRIMARY_KEY
.MoveNext
Loop
.Close
End With
Set rs = Nothing
Set cn = Nothing
End Sub