I don't know whether you are using DAO or ADO but one method is to use ADOX (Microsoft ADO Ext 2.x for DDL and Security):
Code:
Dim catADOX As New ADOX.Catalog
catADOX.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Test Files\db1 XP.mdb;"
For Each keyADOX In catADOX.Tables("Table1").Keys
If keyADOX.type = adKeyPrimary Then
Debug.Print keyADOX.Name
Exit For
End If
Next keyADOX
catADOX.ActiveConnection.Close
Set catADOX = Nothing
Set keyADOX = Nothing
OpenSchema would be another option.
Personally I can't recommend using ODBC with a Jet database since it's not as stable as Jet OLEDB and is lacking in features.
Paul
~~~~
Microsoft MVP (Visual Basic)
Bookmarks