Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Microsoft: Access Forms FAQ

How to

Print table and field names into Immediate window by randysmid
Posted: 6 Dec 02 (Edited 24 Mar 03)

Here is a sample bit of code that will search all the tables and will print table and field names.  This code should be placed in a module.  As you probably know, the Debug.Print statement will put the results in the Immediate window (accessed via CTRL-G).  If necessary, you can then highlight the code and paste into Word, then print.

Public Sub GetTableObjects()
   Dim db As Database
   Dim tbl As TableDef
   Dim Fld As Field
   Set db = CurrentDb
   For Each tbl In db.TableDefs
     Debug.Print "Table: " & tbl.Name & " ***"
       For Each Fld In tbl.Fields
         Debug.Print Fld.Name
       Next Fld
   Next tbl
End Sub

You can easily run this code from inside the Module object.  Open up the module, place the cursor on the title line (Public Sub Get.....), then click the Run Macro button (arrow pointing to the right).

You may need to set some references to get to the different properties (such as tblFields).  Here are the References I have on my database:
   Visual Basic For Applications
   Microsoft Access 9.0 Object Library  (Access 2000)
   Microsoft DAO 3.6 Object Library
   OLE Automation
   Microsoft Visual Basic for Applications Extensibility 5.3
   Microsoft Office 9.0 Object Library

If you are not sure how to set these, you can enter the Microsoft Visual Basic editor (where you enter your code statements), then click on Tools. You can then click on References, then check your current list (they will have check marks in front of each one that is currently being utilized).  Simply click on any missing references, and make sure they are in the order shown above.

Back to Microsoft: Access Forms FAQ Index
Back to Microsoft: Access Forms Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close