DataBase - 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
Debug.Print
(1)
GetIndexes
(1)
TableInfo
(1)
Database
(1)
Msys
(1)
Years
(1)
Func
(1)
Tdf
(1)
  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
Create New Account
help
statement" Any ideas? Thanks! d Access Queries Discussions CurrentDb.TableDefs (1) VB (1) ForeignTableFieldName (1) Debug.Print (1) DbGUID (1) FListTableInfo (1) Database (1) VbCrLf (1) Hi Darhl, I am not familiar As DAO.Index Dim i As Integer Set db = CurrentDb Set tdf = db.TableDefs(pstrTableName) Debug.Print " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = " Debug.Print "INDEX Info for: " & pstrTableName Debug.Print " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = " Debug.Print "Index Count: " & tdf.Indexes.Count For i = 0 To tdf.Indexes.Count - 1
posting) Option Compare Database Option Explicit Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) Debug.Print "Detail Format" Private Sub Detail_Paint() Debug.Print "Detail Paint" Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer) Debug.Print "Detail Print" Private Sub Detail_Retreat() Debug.Print "Detail Retreat" Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer) Debug.Print "Page Header
subs Prac4 and Prac5 below work, but Prac6 does not. The error is in the debug.print statement, not the Set statement. Sub Prac4() Dim FldName As String FldName = CurrentDb().TableDefs(0).Fields(0).Name Debug.Print FldName End Sub Sub Prac5() Dim Dbs As DAO.Database Set Dbs = CurrentDb Debug.Print Dbs.Name End Sub Sub Prac6() Dim Fld As DAO.Field Set Fld = CurrentDb().TableDefs(0).Fields(0) Debug.Print Fld.Name End Sub Access Modules DAO Discussions CurrentDB.SomeObjectProperty.SomeNonObjectProperty (1) CurrentDB.SomeObjectProperty (1
the ActiveX control For j = 0 To CtlSpace.Properties.Count - 10 On Error Resume Next Debug.Print Debug.Print j & " " & CtlSpace.Properties(j).Name & " " & CtlSpace.Properties(j) Next j lists 61 properties, but nothing