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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table of field properties wanted

Status
Not open for further replies.

ednz

Programmer
Jan 15, 2001
19
NZ
I want to create a table of field properties for my database.
One row per table field, with columns table name, field name, field type, description. I can get field properties as numbers , but having trouble translating them. Also cannot find field description programmatically.
I want a more compact summary of my database than the analyzer provides. Can anyone help? Many thanks.
 
You will need something like this
Code:
Private Sub Command9_Click()
    Dim db                          As DAO.Database
    Dim tdf                         As DAO.TableDef
    Dim fld                         As DAO.Field
    
    Dim Desc As String
    Set db = DAO.DBEngine(0).OpenDatabase(".\ChapsMast.mdb")
    Set tdf = db.TableDefs("aaa")
    
    On Error Resume Next
    For Each fld In tdf.Fields
        Desc = ""
        Desc = fld.Properties("Description").Value
        Debug.Print tdf.Name, fld.Name, fld.Type, TypeOfField(fld.Type), Desc
        Err.Clear
    Next
End Sub

Public Function TypeOfField(fldtype As Long) As String
    Select Case fldtype
        Case dbBigInt:      TypeOfField = "BigInt"
        Case dbBinary:      TypeOfField = "Binary"
        Case dbBoolean:     TypeOfField = "Binary"
        Case dbByte:        TypeOfField = "Byte"
        Case dbChar:        TypeOfField = "Char"
        Case dbCurrency:    TypeOfField = "Currency"
        Case dbDate:        TypeOfField = "Date"
        Case dbDecimal:     TypeOfField = "Decimal"
        Case dbDouble:      TypeOfField = "Double"
        Case dbFloat:       TypeOfField = "Float"
        Case dbGUID:        TypeOfField = "GUID"
        Case dbInteger:     TypeOfField = "Integer"
        Case dbLong:        TypeOfField = "Long"
        Case dbLongBinary:  TypeOfField = "LongBinary"
        Case dbMemo:        TypeOfField = "Memo"
        Case dbNumeric:     TypeOfField = "Numeric"
        Case dbSingle:      TypeOfField = "Single"
        Case dbText:        TypeOfField = "Text"
        Case dbTime:        TypeOfField = "Time"
        Case dbTimeStamp:   TypeOfField = "TimeStamp"
        Case dbVarBinary:   TypeOfField = "VarBinary"
        Case Else:          TypeOfField = "Unknown (" & fldtype & ")"
    End Select
End Function
The handling for the Description property can raise an error because that property will exist only for those fields that have been given a description.
 
Many thanks Golom and MajP for fast and thorough responses.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top