Results 1 to 2 of 2
  1. #1
    Lounger
    Join Date
    Jan 2002
    Location
    Rochester, Kent, United Kingdom
    Posts
    32
    Thanks
    0
    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. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 15 Times in 15 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
  •