Field

  • Thread starter Thread starter Georges
  • Start date Start date
I analyzed the DAO TableDefs collection and came up with the following
solution. Simply pass in the table name and column (field) name in question
and the function will return TRUE if the column is indexed. Note that a
little more work is involved if you want to determine if the column has a
unique index or not. I used the Microsoft DAO 3.6 Reference Library.

Public Function IsIndexed(strTableName As String, strColName As String) As
Boolean
Dim T As TableDefs
Dim tdf As TableDef
Dim I As DAO.Indexes
Dim idx As DAO.Index
Set T = CurrentDb.TableDefs
For Each tdf In T
If tdf.Name = strTableName Then
Set I = tdf.Indexes
For Each idx In I
If idx.Name = strColName Then
IsIndexed = True
Exit Function
End If
Next
End If
Next
End Function

Hope this helps.
Reid.
 
Back
Top