Applecore Pages on Microsoft Access

Getting Field Descriptions from Code

In order to get the descriptions that have been entered for Fields in a Table, you will need to loop through the table, and then each field within that table. You will also need to carefully trap for any errors which will be generated if the Field hasn't had a Description created for it:

Sub sListFieldDescriptions()
    On Error GoTo E_Handle
    Dim db As Database
    Dim tdf As TableDef
    Dim fld As Field
    Set db=DBengine(0)(0)
    For Each tdf In db.TableDefs
        If Left(tdf.Name,4)<>"MSys" Then
            Debug.Print tdf.Name
            For Each fld in tdf.Fields
                Debug.Print vbTab & fld.Name & vbTab & fld.Properties("Description")
            Next fld
        End If
    Next tdf
sExit:
    Set db=Nothing
    Exit Sub
E_Handle:
    Select Case Err.Number
        Case 3270
            Debug.Print vbTab & fld.Name & vbTab & "n/a"
            Resume Next
        Case Else
            MsgBox Err.Description,vbOKOnly+vbCritical,"Error: " & Err.Number
            Resume sExit
    End Select
End Sub

Top

 


HOME | NEW | TABLES | QUERIES | FORMS | REPORTS | GENERAL | API | DOWNLOADS | TUTORIAL | RESOURCES
E-MAIL
Copyright & Disclaimer

 

Last modified at 06/06/2006 15:00:30