Closing Open Queries

Rog

New member
Local time
Today, 18:33
Joined
Jul 31, 2001
Messages
8
I do a lot of data scrubbing and have built a form to run a selection of queries within a database. Trouble is that I often finish with lots of select queries open at the end of the run. Sometimes I want to look at them. Sometimes I don't. How do I identify the open queries within my databse so I can close them?
 
try this:

Const conObjStateClosed = 0
Const conDesignView = 0
Dim strRowSource As String
Dim db As Database
Dim qdf As QueryDef
Dim i As Integer
Set db = CurrentDb()
For i = 0 To db.QueryDefs.Count - 1
If SysCmd(acSysCmdGetObjectState, acQuery, db.QueryDefs(i).Name) <> conObjStateClosed Then

strRowSource = strRowSource & db.QueryDefs(i).Name & ";"

End If
Next i
Me.List3.RowSource = strRowSource
End Sub

You may need to explicitly reference the database(use DAO.Database instead of Database in the declarations) if you are using A2K

Ian
 
That's brilliant. Works a treat now.
 

Users who are viewing this thread

Back
Top Bottom