get query description programmatically

  • Thread starter Thread starter Judy W.
  • Start date Start date
J

Judy W.

I need to 'tag' my queries so that I can position them
appropriately on the screen when invoked from a form
according to the quantity/shape of the resulting
datasheet. I thought of making a note in the Description
field but then I cannot seem to get to it from code.

Can I do this? or can I 'tag' my queries in some other
way that I can then read from code, without having to
know the specific name of each query? (I will have about
4 varieties of 'presentation' styles, but 30 or so
queries the user can choose from.) I don't want to need
to know the name of each specifically, just
to 'categorize' each query for presentation.
 
Judy W. said:
I need to 'tag' my queries so that I can position them
appropriately on the screen when invoked from a form
according to the quantity/shape of the resulting
datasheet. I thought of making a note in the Description
field but then I cannot seem to get to it from code.

Can I do this? or can I 'tag' my queries in some other
way that I can then read from code, without having to
know the specific name of each query? (I will have about
4 varieties of 'presentation' styles, but 30 or so
queries the user can choose from.) I don't want to need
to know the name of each specifically, just
to 'categorize' each query for presentation.

Using DAO, you can read a query's Description property, provided it has
one, by way of the QueryDef object representing it. If the query
doesn't have a description, though, trying to read it will raise a
trappable error. You might use code like this:

On Error GoTo Your_Normal_Error_Handler

Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strQueryDescription As String

Set db = CurrentDb
Set qdf = db.QueryDefs("MyQuery")

strQueryDescription = vbNullString

On Error Resume Next
strQueryDescription = qdf.Properties("Description")
On Error GoTo Your_Normal_Error_Handler

Set qdf = Nothing
Set db = Nothing

' At this point, strQueryDescription either contains the query's
description,
' or it contains a zero-length string.
 
Or just store the names/descriptions in a seperate table. Not pretty, but
it works.

--
Chris

Please respond to newsgroups, as I
don't check this address very often.
 
Back
Top