Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    233

    Unanswered: Print list of field names for each table

    I need to print a list of field names for each tbl in my db. I dont know if there is any other way than using tabledef if there is a better way pls let me know. also i cant figure how to print the fields in a table, here is my code:

    Sub displayTableFields()

    Dim i, j As Integer

    For i = 0 To CurrentDb.TableDefs.count - 1

    Debug.Print CurrentDb.TableDefs(i).Name 'Debug.Print CurrentDb.TableDefs(i).Type

    For j = 1 To CurrentDb.TableDefs(j).Fields.count - 1
    Debug.Print CurrentDb.TableDefs(j).Fields

    Next j

    Next i
    End Sub

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    you could do it more elegantly with:
    Code:
        Dim aField As DAO.Field
        Dim aTable As DAO.TableDef
        For Each aTable In CurrentDb.TableDefs
            Debug.Print aTable.Name
            For Each aField In aTable.Fields
                Debug.Print "-" & aField.Name
            Next
        Next
    ...or you could look at the documenter (Tools/Analyze/Documenter/Tables and adjust the Options

    izy
    currently using SS 2008R2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •