Foreign Property Example (MDB)

The following example prints the value of the Foreign property for each index in an Orders table:

Sub CheckForeign()
    Dim dbs As Database, tdf As TableDef, idx As Index

    ' Return reference to current database.
    Set dbs = CurrentDb
    ' Return reference to Orders table.
    Set tdf = dbs.TableDefs!Orders
    ' Enumerate through Indexes collection of table.
    For Each idx In tdf.Indexes
        ' Print value of Foreign property.
        Debug.Print idx.Name; "        "; idx.Foreign
    Next idx
    Set dbs = Nothing
End Sub