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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete all queries in a database

Status
Not open for further replies.

eerich

IS-IT--Management
Nov 2, 2003
124
US
Is there a way to delete all the queries within a database at once? Is it possible to write a SQL statement or Macro to handle the deletion?

Thanks.
 
I think it might be better in this case to exclude system queries.

Code:
   i = CurrentDb.QueryDefs.Count
   For n = 0 To i - 1
      strHold = CurrentDb.QueryDefs(n).Name
      'This next line is the one that will do the damage
      If Left(strHold, 1) <> "~" Then
      'CurrentDb.QueryDefs.Delete strHold
        Debug.Print strHold
      End If
   Next n
   CurrentDb.QueryDefs.Refresh
 
Sometimes this will also cause amusement, as what happens when you remove the first item from a collection?

[tt] i = CurrentDb.QueryDefs.Count
For n = i - 1 To 0 Step - 1[/tt]



Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top