Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Multiple Objects 1

Status
Not open for further replies.

tms05

Technical User
Apr 2, 2003
21
US
Is there any way to delete multiple queries, forms or reports at once with out doing one by one. I have been able to accomplish deleting multiple tables but can't figure out how to do the queries, forms, or reports. Our database has 6 users all which create queries and reports and it seems a new one is created each time they need something. SO, we have numberous unused queries and reports and I need to delete those. There are so many, it would take me forever if I did one at a time. Also, is there a way to be able to tell when the last time the query was accessed???
 
Hi,

If you could persuade your users to be disciplined in naming their queries, e.g. by prefixing them all with user_, then you could clean them up programtically.

Code:
Public Sub RemoveOldQueries(dtmCreatedBefore As Date)

    Dim daoDB As DAO.Database
    Dim daoQDF As DAO.QueryDef
    
    Set daoDB = CurrentDb()
    
    For Each daoQDF In daoDB.QueryDefs
        If Mid$(daoQDF.Name, 1, 4) = "user_" Then
            If daoQDF.DateCreated <= dtmCreatedBefore Then
                DoCmd.DeleteObject acQuery, daoQDF.Name
            End If
        End If
    Next daoQDF
    
    
End Sub
 
That was perfect. It allows me to use the Like expression, therefore I was able to do what I needed. I have looked for hours (probably over 50 hrs) for a solution to this problem. THANKS!!!!
 
How would you do reports or forms?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top