Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA code to print a list of tables (with fields)

Tables and Relationships

VBA code to print a list of tables (with fields)

by  randysmid  Posted    (Edited  )
Hi,
Here is VBA code that will print a list of non-system tables within a database. Optionally, it will print a list of all fields as well. The output for this will go into the Immediate Window, which is accessible via CTRL-G. The results of this can be dropped into Word, or even Notepad for printing.

You may want to place this code into a new Module, perhaps called "modTableInfo".

Public Sub GetTableInfo()
Dim db As Database, tbl As TableDef, fld As Field
Set db = CurrentDb
Debug.Print " ", db.Name
Debug.Print " "
Debug.Print "Table Created Modified # Recs"
Debug.Print "----- ------- -------- ------"
For Each tbl In db.TableDefs
If Left$(tbl.Name, 4) <> "MSys" Then
Debug.Print tbl.Name & " " & tbl.DateCreated & " " & _
tbl.LastUpdated & " " & tbl.RecordCount
' optional code to print all the fields
'For Each fld In tbl.Fields
' Debug.Print fld.Name
'Next fld
End If
Next tbl
End Sub
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top