PsychoDazey
asked on
Generate list of field names and descriptions for tables in Access
I have the following code I am running to build a data dictionary. I want the dictionary to contain field names and descriptions for each table. I can get the names fine, I just can't figure out how to get the descriptions. Here is my code:
Sub ExamineTable(TableName As String)
Dim currentDB As Database
Dim mytable As TableDef
Dim fieldName As String
Dim fieldDescription As String
Dim i As Integer
Set currentDB = Application.currentDB
Set mytable = currentDB.TableDefs(TableN ame)
For i = 0 To mytable.Fields.Count - 1
fieldName = mytable.Fields(i).Name
'THIS IS WHERE IT BLOWS UP (BELOW). I DONT KNOW HOW TO ACCESS THE DESCRIPTION OR CAPTION
fieldDescription = mytable.Fields(i).Descript ion
DoCmd.RunSQL "Insert tblDictionary (FieldName, FieldDescription) " _
& "Values ('" & fieldName & "','" & fieldDescription & "');"
Next i
End Sub
Sub ExamineTable(TableName As String)
Dim currentDB As Database
Dim mytable As TableDef
Dim fieldName As String
Dim fieldDescription As String
Dim i As Integer
Set currentDB = Application.currentDB
Set mytable = currentDB.TableDefs(TableN
For i = 0 To mytable.Fields.Count - 1
fieldName = mytable.Fields(i).Name
'THIS IS WHERE IT BLOWS UP (BELOW). I DONT KNOW HOW TO ACCESS THE DESCRIPTION OR CAPTION
fieldDescription = mytable.Fields(i).Descript
DoCmd.RunSQL "Insert tblDictionary (FieldName, FieldDescription) " _
& "Values ('" & fieldName & "','" & fieldDescription & "');"
Next i
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, appreciate the help!
ASKER
Replace(fld.Properties("De