Access ADP Tables and Fields

This is how to list all Tables and Fields in an Access Database Project (ADP).

Option Compare Database
Option Explicit

Public Sub ListTablesAndFieldsADP()
    '---------------------------------------------------------------------
    'Reference is needed for: Microsoft ADO Ext. 2.x for DDL and Security
    '---------------------------------------------------------------------
    Dim cat As New ADOX.Catalog 
    Dim tbl As ADOX.Table       
    Dim col As ADOX.Column       
    Dim fs As Object
    Dim output As Object

    Set fs = CreateObject("Scripting.FileSystemObject")
    Set output = fs.CreateTextFile("c:\Tables_Views_And_Fields.txt", True)
    
    Set cat.ActiveConnection = CurrentProject.Connection
    
    For Each tbl In cat.Tables
        If Left(tbl.Type, 6) <> "SYSTEM" Then
            output.WriteLine tbl.Name & " (" & tbl.Type & ")"
            For Each col In tbl.Columns
                output.WriteLine "  " & col.Name
            Next
            output.WriteLine
        End If
    Next
    
    Set col = Nothing
    Set tbl = Nothing
    Set cat = Nothing
End Sub

Comments are closed