Document field descriptions

S

SAC

I'd like to print out the table names, fields names, types, sizes, and
description for a database.

I can iterate through all the tables and fields names, but when I try to
find the description property it's not available.

I've entered the descriptions of the fields in the table design.

How can I get the description of a field?

Thanks.
 
D

Douglas J Steele

While you refer, for instance, to tblCurr.Name and fldCurr.Name, you need to
refer to tblCurr.Properties("Description") and
fldCurr.Properties("Description").

There's a problem with that, though. The Description property does not exist
unless you set the description. If you try to refer to the Description
property for a table or field that doesn't have a description, an error will
be raised. You'll either have to use On Error Resume Next, or else set your
error handling to bypass the specific error that's raised (sorry, I don't
remember its number off the top of my head)
 
S

SAC

I tried that and I get and error saying "Property not found."

I'm using the DAO 3.6 Object Library.

To test I if I change ...("Description") to ("Name") it works.

Here's the code:

Function fDocumentTables()
Dim DB As Database
Dim Rs As Recordset
Dim i As Integer
Dim lngI As Long

'Set db = DBEngine.Workspaces(0).Databases(0)
Set DB = CurrentDb
'Set rs = db.OpenRecordset("tblDocumentation", dbOpenDynaset)

'Set rs = db.OpenRecordset("SELECT tblDocumentation.tblName,
tblDocumentation.fldName, tblDocumentation.fldType, " _
'& "tblDocumentation.fldSize, tblDocumentation.fldDesc " _
'& "FROM tblDocumentation;", dbOpenDynaset)
DB.TableDefs.Refresh

'Iterate through the tables
For i = 0 To DB.TableDefs.Count - 1
MsgBox (DB.TableDefs(i).Name)

'Now iterate through the fields
For lngI = 0 To DB.TableDefs(i).Fields.Count - 1


'This is for testing
MsgBox (DB.TableDefs(i).Name)
MsgBox (DB.TableDefs(i).Fields(lngI).Name)
MsgBox (DB.TableDefs(i).Fields(lngI).Type)
MsgBox (DB.TableDefs(i).Fields(lngI).Size)
MsgBox (DB.TableDefs(i).Fields(lngI).Properties("Description"))
'End testing


'rs.AddNew
'rs!tblName = db.TableDefs(i).Name
'rs!fldName = db.TableDefs(i).Fields(lngI).Name
'rs!fldType = db.TableDefs(i).Fields(lngI).Type
'rs!fldSize = db.TableDefs(i).Fields(lngI).Size
'rs!fldDesc =
db.TableDefs(i).Fields(lngI).Properties("Description")
'rs.Update

Next lngI
Next i

Set Rs = Nothing
Set DB = Nothing

End Function

Any ideas?

Thanks
 
S

SAC

Thanks, Doug. I got it. The problem was null descriptions just like you
said so I put in an "On error resume next" for now.

Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top