Hey Larry thanks yourself and Hi--I haven't "seen" you in a while. I recently posted this and don't remember the thread--not trying to blow my own horn here, but I LOVE this routine because it makes a great data dictionary with column descriptions and table descriptions (**and error ignored if they're not there--Tony pointed out above that the Description property is not a permanent member of the properties collection--it only exists if a description is created for table or field):
Cheers!
[tt]
Public Sub DocumentTables()
'Requires function FieldType
On Error GoTo Error_DocumentTables
Dim DB As DAO.Database
Dim Rs As DAO.Recordset
Dim TDF As DAO.TableDef
Dim FLD As DAO.Field
Dim strSQL_DROP As String
Dim strSQL_CREATE As String
'Delete existing copy of this table
strSQL_DROP = "DROP TABLE data_dictionary;"
DoCmd.RunSQL strSQL_DROP
strSQL_CREATE = "CREATE TABLE data_dictionary" & _
"(table_name varchar(50),table_description varchar(100), field_name varchar(50),field_description varchar(100)," & _
"ordinal_position NUMBER, data_type varchar(15)," & _
"length varchar(5), default varchar(30), primary_key varchar(10)," & _
"nullable varchar(20));"
DoCmd.RunSQL strSQL_CREATE
Set DB = CurrentDb()
Set Rs = DB.OpenRecordset("data_dictionary"
With Rs
For Each TDF In DB.TableDefs
If Left(TDF.NAME, 4) <> "Msys" Then
For Each FLD In TDF.Fields
.AddNew
!table_name = TDF.NAME
!table_description = TDF.Properties("description"

!field_name = FLD.NAME
!field_description = FLD.Properties("description"

!ordinal_position = FLD.OrdinalPosition
!data_type = FieldType(FLD.TYPE)
!length = FLD.Size
!Default = FLD.DefaultValue
!nullable = "YES"
If FLD.REQUIRED Then
!nullable = "NO"
End If
.Update
Next
End If
Next
End With
MsgBox "Tables have been documented", vbInformation, "TABLES DOCUMENTED"
Rs.Close
DB.Close
Exit_Error_DocumentTables:
Set TDF = Nothing
Set Rs = Nothing
Set DB = Nothing
Exit Sub
Error_DocumentTables:
Select Case Err.Number
Case 3376
Resume Next 'Ignore error if table not found
Case 3270 'Property Not Found
Resume Next
Case Else
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Error_DocumentTables
End Select
End Sub
Private Function FieldType(v_fldtype As Integer) As String
On Error GoTo Error_FieldType
Select Case v_fldtype
Case dbBoolean
FieldType = "Boolean"
Case dbByte
FieldType = "Byte"
Case dbInteger
FieldType = "Integer"
Case dbLong
FieldType = "Long"
Case dbCurrency
FieldType = "Currency"
Case dbSingle
FieldType = "Single"
Case dbDouble
FieldType = "Double"
Case dbDate
FieldType = "Date"
Case dbText
FieldType = "Text"
Case dbLongBinary
FieldType = "LongBinary"
Case dbMemo
FieldType = "Memo"
Case dbGUID
FieldType = "GUID"
End Select
Exit_Error_Fieldtype:
Exit Function
Error_FieldType:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Error_Fieldtype
End Function
[/tt]
Jeffrey R. Roberts
Insight Data Consulting
Access, SQL Server, & Oracle Development