How to get object descriptions through VBA code

  • Thread starter Thread starter Paul Norris
  • Start date Start date
P

Paul Norris

I'm looking to find a way to access object descriptions in an Access
(DAO) database. For example, I want to be able to access and
manipulate the descriptions that appear for fields in tables, and for
queries, tables, forms and reports in the main database window. The
purpose is to be able to create reports that document the database
itself.

I've looked at the object model and can't find how these items can be
accessed. Are they exposed to the DAO object model? Is there some
other trick I could use to make better use of these descriptions?

Paul Norris
University of California San Francisco
 
You'd refer to the Description property of the object. The "trick" is,
though, that the Description property doesn't exist unless you've assigned a
description: you get an error when you try to access it when no description
exists.

To get the description of all tables, for example, you could use something
like:

Dim dbCurr As DAO.Database
Dim prpCurr As DAO.Property
Dim tblCurr As DAO.TableDef
dim strDescription As String

On Error Resume Next

Set dbCurr = CurrentDb()
For Each tblCurr In dbCurr.TableDefs
strDescription = tblCurr.Properties("Description")
If Err.Number = 3270 Then ' 3270 is "Property Not Found"
strDescription = "N/A"
End If
Debug.Print tblCurr.Name & ": " & strDescription
Next tblCurr
 
Back
Top