• Query descriptions created in code (97)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Query descriptions created in code (97)

    Author
    Topic
    #374777

    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

    Viewing 1 reply thread
    Author
    Replies
    • #607464

      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.

    • #607523

      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:

      Public Function CreateTempQry()
        Dim dbs As DAO.Database
        Dim qdf As DAO.QueryDef
         
        Set dbs = CurrentDb
        Set qdf = dbs.CreateQueryDef("qryTestQry", "SELECT * FROM Customers")
        'now use the object to set its description
        qdf.Properties("Description") = "Test it"
        'see what the description was set to  
        Debug.Print qdf.Properties("Description")
       
        Set qdf = Nothing
        Set dbs = Nothing
      End Function
    Viewing 1 reply thread
    Reply To: Query descriptions created in code (97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: