> What version of Access are you using? That code should be fine in all
> versions since Access 2000: it's essentially the same code as in
>
http://msdn.microsoft.com/library/en-us/vbaac11/html/accolAllQueries_HV05251615.asp>
> If you're still using Access 97 or earlier, try:
>
> Dim db As DAO.Database
> Dim qry As DAO.QueryDef
> Dim intLoop As Integer
>
> Set db = CurrentDb()
> For intLoop = (db.QueryDefs.Count - 1) To 0 Step -1
> Set qry = db.QueryDefs(intLoop)
> If Syscmd(acSysCmdGetObjectState , acQuery, qdf.Name) > 0 Then
> DoCmd.Close acQuery,. qdf.Name
> End If
> Next intLoop
> Set db = Nothing
>
> --
> Doug Steele, Microsoft Access MVP
>
http://I.Am/DougSteele> (no e-mails, please!)
>
>
> "cseifferly" <cseifferly[ at ]discussions.microsoft.com> wrote in message
> news:4F2178C1-39AE-43C0-B336-F587A904FFE0[ at ]microsoft.com...
> > There's got to be something I'm missing here. Is there a particular
> > reference I need to add in order to use "AccessObject" as a datatype and
> > "db.AllQueries"? Also, should "Set db = Application.CurrentData read "Set
> > db
> > = Application.CurrentDb"?
> >
> > This code won't actually run for me.
> >
> >>
> >> Dim db As Object
> >> Dim qry As AccessObject
> >> Set db = Application.CurrentData
> >> For Each qry In db.AllQueries
> >> If qry.IsLoaded _
> >> Then DoCmd.Close acQuery, qry.Name
> >> Next qry
> >> Set db = Nothing
> >>
> >> Note that IsLoaded applies to all AccessObjects, not just
> >> forms. The QueryDef object does not have an equivalent to
> >> the IsLoaded property and there is no Queries collection in
> >> the Application object.
> >>
> >
>
>
>