Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Deleting queries (2003)

    Is there a way to delete more than one query at a time. I want to reuse a database and I have a lot of queries to delete. Maybe this is easier than I am making it. Thanks for your help....

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

    Re: Deleting queries (2003)

    You can delete only one query at a time interactively.
    If you want to delete *all* queries, it is easy to write VBA code to do it.
    If you want to delete specific queries, it would be possible to create a form with a multi-select list box and a "Delete" command button, but it might be just as quick to delete the queries manually.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Deleting queries (2003)

    I tried to use a macro using the DeleteObject. I put report for the object and then the name I tried to use *. For example HBrpt_*. So I would delete everything that started with HBrpt_ but it didn't work. Does anyone know what the syntax would be for this DeleteObject?

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

    Re: Deleting queries (2003)

    For example:
    <code>
    Sub RemoveQueries()
    Dim i As Integer
    Dim qrs As Object
    Set qrs = CurrentData.AllQueries
    For i = qrs.Count - 1 To 0 Step -1
    If qrs(i).Name Like "HBRpt_*" Then
    DoCmd.DeleteObject acQuery, qrs(i).Name
    End If
    Next i
    Set qrs = Nothing
    End Sub
    </code>
    or
    <code>
    Sub RemoveQueries()
    Dim dbs As DAO.Database
    Dim i As Integer
    Set dbs = CurrentDb
    For i = dbs.QueryDefs.Count - 1 To 0 Step -1
    If dbs.QueryDefs(i).Name Like "HBRpt_*" Then
    dbs.QueryDefs.Delete dbs.QueryDefs(i).Name
    End If
    Next i
    Set dbs = Nothing
    End Sub</code>

Posting Permissions

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