Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Oct 2002
    Location
    Toronto, Ontario, Canada
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Query description (Access 2000)

    Is there a way to access the description of a query in code?
    When I create a query I will usually put in a bit of a description in the query properties box.
    I have a form in Access 2000 as an interface which allows users to run some queries and I would like to be able to add the query description to a text box when they select a query. Does that make sense.

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Query description (Access 2000)

    This little code will print the description of a query in the immediate window :
    <pre>Dim db As DAO.Database
    Dim qdf As QueryDef
    Set db = CurrentDb
    Set qdf = db.QueryDefs("YourQuery")
    Debug.Print qdf.Properties("description")</pre>

    Francois

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Query description (Access 2000)

    The DAO QueryDef object exposes the Properties collection. If a description has been added to a query, you can retrieve it, but error 3270 occurs if there is no description. For the following code to work, you must set a reference to the Microsoft DAO 3.6 Object Library in Tools | References...

    Function GetDescription(QueryName As String) As String
    On Error GoTo ErrHandler
    GetDescription = CurrentDb.QueryDefs(QueryName).Properties("Descrip tion")
    Exit Function
    ErrHandler:
    If Not (Err = 3270) Then
    MsgBox Err.Description, vbExclamation
    End If
    End Function


    Example of use:

    MsgBox GetDescription("qryCustomers")

  4. #4
    New Lounger
    Join Date
    Oct 2002
    Location
    Toronto, Ontario, Canada
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Query description (Access 2000)

    Thanks, I new it was something simple. Works great

  5. #5
    New Lounger
    Join Date
    Oct 2002
    Location
    Toronto, Ontario, Canada
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Query description (Access 2000)

    Thank you too! I found out about the error 3270 pretty quickly and I handled it similiar to your example.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •