Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2002
    Rochester, Kent, United Kingdom
    Thanked 0 Times in 0 Posts

    Keys in tables (XP)

    Does anybody have any code to check which filelds are keyed?
    Any help much appreaciated

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Keys in tables (XP)

    You can use Tools | Analyze | Documenter to produce a report documenting your database. If you click Options in the Tables tab, you can specify which information about indexes (keys) is included.

    Here is some code that will list all indexes and their fields in the Immediate window. You can adapt the code to your needs. The code requires a reference (in Tools | References...) to the Microsoft DAO 3.6 Object Library.

    Sub ListIndexes()
    Dim dbs As DAO.Database
    Dim tbl As DAO.TableDef
    Dim idx As DAO.Index
    Dim fld As DAO.Field

    Set dbs = CurrentDb
    For Each tbl In dbs.TableDefs
    If Left(tbl.Name, 4) <> "MSys" Then
    Debug.Print tbl.Name
    For Each idx In tbl.Indexes
    Debug.Print vbTab & idx.Name & IIf(idx.Primary, " *", "")
    For Each fld In idx.Fields
    Debug.Print vbTab & vbTab & fld.Name
    Next fld
    Next idx
    End If
    Next tbl

    Set fld = Nothing
    Set idx = Nothing
    Set tbl = Nothing
    Set dbs = Nothing
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts