Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Query descriptions created in code (97)

    Query descriptions created in code
    I used the below to try & create a temporary query that will be routinely created & deleted whenever it is called. The below code is meant to create it & append a description to the query in case sometime in the future I forget what it

  2. #2
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Richland, Washington, USA
    Posts
    407
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Query descriptions created in code (97)

    I'm not sure what your line 'db.QueryDefs("qryEnterPayDetails").Properties ("Test desc")' is supposed to accomplish (this is the line that's generating the error, right?). The syntax suggests that you are trying to reference the "Test desc" property of the query def, but that's not a normal property. If it were (e.g., "Name", "DateCreated", etc.), you might want to look at it or assign it's value to a variable or something like that, but your code isn't doing that. Try removing that line and see if you then get what you want.

    Hope this helps.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Query descriptions created in code (97)

    I think your problem may be that you're creating the querydef and instantiating the querydef object, but then you're not using that object to set the property. You may have noticed that database window list don't refresh right away, and I suspect you're running into something similar. The following code works on my machine in Access 2000 to create a querydef and set its description property:

    <pre>Public Function CreateTempQry()
    Dim dbs As DAO.Database
    Dim qdf As DAO.QueryDef

    Set dbs = CurrentDb
    Set qdf = dbs.CreateQueryDef("qryTestQry", "SELECT * FROM Customers")
    '<font color=448800>now use the object to set its description</font color=448800>
    qdf.Properties("Description") = "Test it"
    '<font color=448800>see what the description was set to</font color=448800>
    Debug.Print qdf.Properties("Description")

    Set qdf = Nothing
    Set dbs = Nothing
    End Function</pre>

    Charlotte

Posting Permissions

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