Indexes, Primary Keys and Relationships in MS Access

  • Thread starter Thread starter Naveen
  • Start date Start date
N

Naveen

Hi,

How can i query/get the following in an MS Access 2002
Database: -

1. List of Indexed Fields in the MDB
2. All the Primary Key Fields in the MDB
3. List of Constraints/Foreign Key relationships in the MDB

Is there some way to query this information instead of
going table by table in the design view?

Thanks!
 
You can access these things programmatically.

This example lists the names of the relationships in the current database,
including the table and foreign table. Each relation has other properties as
well.

Function ShowRel()
Dim db As DAO.Database
Dim rel As DAO.Relation

Set db = CurrentDb()
For Each rel In db.Relations
Debug.Print rel.Name, rel.Table, rel.ForeignTable
Next

Set rel = Nothing
Set db = Nothing
End Function
 
Thanks! This works.

I was curious to know if there was some way to query the
MDB and get the information instead of coding.

Thank you,
 
This is undocumented, but may help:

SELECT MSysRelationships.* FROM MSysRelationships;
 
Thanks!
-----Original Message-----
This is undocumented, but may help:

SELECT MSysRelationships.* FROM MSysRelationships;

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.




.
 
Back
Top