472,145 Members | 1,390 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

Where are Indexes and Relationships stored, within Access MDB file?

Hello folks,

I'm developing a program that reads an access MDB file and produce
some scripts to rebuild the same structure against other databases
(MSSQL, MySQL and so on).

Reading structure of tables and fields was quite simple. Now I'm stuck
because I can't find where to read to access infos about indexes and
relationships. Probably for relationships I've to read the hidden
table MSysRelationships (I didn't do that 'till now), but I haven't
found anything about indexes.

Any suggestion?

TIA, tK
Nov 13 '05 #1
2 3148
Check the Relations collection:

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

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

Set fld = Nothing
Set rel = Nothing
Set db = Nothing
End Function
Indexes belong to a TableDef:

Function ShowIndexes(strTable As String)
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim ind As DAO.Index
Dim fld As DAO.Field

Set db = DBEngine(0)(0)
Set tdf = db.TableDefs(strTable)
For Each ind In tdf.Indexes
Debug.Print ind.Name, IIf(ind.Primary, "Primary", ""), _
IIf(ind.Foreign, "Foreign", ""), ind.Fields.Count
Debug.Print " Field(s): ";
For Each fld In ind.Fields
Debug.Print fld.Name;
Next
Debug.Print
Next

Set ind = Nothing
Set tdf = Nothing
Set db = Nothing
End Function

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"tekanet" <te*****@inwind.it> wrote in message
news:81**************************@posting.google.c om...

I'm developing a program that reads an access MDB file and produce
some scripts to rebuild the same structure against other databases
(MSSQL, MySQL and so on).

Reading structure of tables and fields was quite simple. Now I'm stuck
because I can't find where to read to access infos about indexes and
relationships. Probably for relationships I've to read the hidden
table MSysRelationships (I didn't do that 'till now), but I haven't
found anything about indexes.

Any suggestion?

TIA, tK

Nov 13 '05 #2
te*****@inwind.it (tekanet) wrote in message news:<81**************************@posting.google. com>...
Hello folks,

I'm developing a program that reads an access MDB file and produce
some scripts to rebuild the same structure against other databases
(MSSQL, MySQL and so on).

Reading structure of tables and fields was quite simple. Now I'm stuck
because I can't find where to read to access infos about indexes and
relationships. Probably for relationships I've to read the hidden
table MSysRelationships (I didn't do that 'till now), but I haven't
found anything about indexes.

Any suggestion?

TIA, tK


If you're good enough at programming to be digging around the guts of
Access, you should probably own the Access Developer's Handbook by
Getz, Litwin, Gilbert/Gunderloy. there's code in there that does that
kind of thing - free with the book and very well worth the price of
the book.
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.