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!

how to reference ACCESS table description with VBA

Status
Not open for further replies.

BradVT

Programmer
Dec 8, 2008
4
US
ACCESS 2003

I want to create a simple list of tables, fileds and field descriptions for my Access 2003 application.

In table design mode, each field has a field name, data type and "description" column for documenting.

Example: Filed Name = "Bind_Date", Data Type = Date/Time and a description of "added 1/17/2006 used for retention and succession vakidation"

I have code to get the table name and field name but I cannot figure out how to reference and get the value in the field description.

Can anybody bail me out?

Thanks,
Brad
Burlington, VT

Here is the code I am using:

Sub List_Tables_Fields_Description()

Dim Dbs As DAO.Database
Dim tbl As DAO.TableDef
Dim fld As DAO.Field

Dim i
Dim strTableName As String

Set Dbs = CurrentDb()
With Dbs

For Each i In .TableDefs 'Look thru tabledef collection f

Set tbl = Dbs.TableDefs(i.Name)
If InStr(1, i.Name, "MSYS") = 0 Then

If i.Name = "INCOMING_DATA" Then 'Testing

For Each fld In tbl.Fields

Debug.Print "Table Name: " & tbl.Name _
& " Field Ordinal Position: " & fld.OrdinalPosition _
& " Field Name: " & fld.Name _
& " Field Type: " & fld.Type _
& " Field Size: " & fld.Size

Next fld
End If 'Testing
End If
Next i
End With
msgbox "All Done"
Dbs.Close
Set Dbs = Nothing
End Sub
 
The description is a property of the field. Note however that, if no value has been defined then that property will not exist.
Code:
On Error Resume Next
Debug.Print fld.Properties("Description").Value
 
description is a property of the field.
Not quite. As you have shown, "Description" is an Index to the properties collection. The properties collection is a property of a fld object.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top