Debug.Print
(1)
GetIndexes
(1)
TableInfo
(1)
Database
(1)
Msys
(1)
Years
(1)
Func
(1)
Tdf
(1)

Get Access Database Schema - Primary Keys and Indexes

Asked By T2B
04-Feb-10 05:45 PM
Is there a function similar to Allen Browne's tableInfo that will pull
in primary key and index schema?

This is Allen's

http://members.iinet.net.au/~allenbrowne/func-06.html

If you want something quick & dirty, I just cobbled this together:Function

Arvin Meyer [MVP] replied to T2B
04-Feb-10 06:27 PM
If you want something quick & dirty, I just cobbled this together:

Function GetIndexes()
' Arvin Meyer 2/4/2010
On Error Resume Next

Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim idx As DAO.index

Set db = CurrentDb

For Each tdf In db.TableDefs
If Left(tdf.Name, 4) <> "Msys" Then
For Each idx In tdf.Indexes
Debug.Print tdf.Name, idx.Name
Next
End If
Next

Exit_Here:
Set db = Nothing
Set tdf = Nothing
Set idx = Nothing

End Function

If you want something more sophisticated, I wrote a dozen years ago that
adds them to a table.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
Post Question To EggHeadCafe