Printing a query's description with its name

  • Thread starter Thread starter Ian Millward
  • Start date Start date
I

Ian Millward

I want to Debug.Print the names and descriptions of all the queries in my
QueryDefs Collection but I can't find a way to surface the Descriptions
property. I am able to set it in the 'Query Properties' Dialog from the
Design View but it doesn't form part of the Properties set of a QueryDef.

Any ideas?

Ian Millward
Edinburgh
 
Assuming you have a reference set to DAO, the following will return the
query's description if it has one:

CurrentDb().QueryDefs("queryname").Properties("Description")

However, it'll raise an error 3270 (property not found) for any queries that
don't have a description, so you'll have to trap those errors.
 
Ian said:
I want to Debug.Print the names and descriptions of all the queries in my
QueryDefs Collection but I can't find a way to surface the Descriptions
property. I am able to set it in the 'Query Properties' Dialog from the
Design View but it doesn't form part of the Properties set of a QueryDef.


On Error Resume Next
For Each qdf In db.QueryDefs
If Left(qdf.Name, 1) <> "~" Then
strDescr = ""
strDescr = qdf.Properties("Description")
Debug.Print qdf.Name, strDescr
End If
Next qdf

The reason for strDescr = "" is that if you nave not
specified a description, then the property does not exist
and refering to it will generate an error.
 
Back
Top