AllQueries Collection [Access 2003 VBA Language Reference]
Multiple objects AllQueries AccessObject AccessObjectProperties |
The AllQueries collection contains an AccessObject for each query in the CurrentData or CodeData object.
Using the AllQueries Collection
The CurrentData or CodeData object has an AllQueries collection containing AccessObject objects that describe instances of all queries specified by CurrentData or CodeData. For example, you can enumerate the AllQueries collection in Visual Basic to set or return the values of properties of individual AccessObject objects in the collection.
Tip
For Each...Next
You can refer to an individual AccessObject object in the AllQueries collection either by referring to the object by name, or by referring to its index within the collection. If you want to refer to a specific object in the AllQueries collection, it's better to refer to the query by name because a query's collection index may change.
The AllQueries collection is indexed beginning with zero. If you refer to a query by its index, the first query is AllQueries(0), the second query is AllQueries(1), and so on.
Notes
The AllQueries collection only contains AccessObject objects within a Microsoft Access database (.mdb). A Microsoft Access project (.adp) does not contain any macros, see the AllViews collection.
To list all open queries in the database, use the IsLoaded property of each AccessObject object in the AllQueries collection. You can then use the Name property of each individual AccessObject object to return the name of a query.
You can't add or delete an AccessObject object from the AllQueries collection.
The following example prints the name of each open AccessObject object in the AllQueries collection.
Sub AllQueries()
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentData
' Search for open AccessObject objects in AllQueries collection.
For Each obj In dbs.AllQueries
If obj.IsLoaded = True Then
' Print name of obj.
Debug.Print obj.Name
End If
Next obj
End Sub
Properties | Count Property | Item Property
Parent Objects | CodeData | CurrentData
Child Objects | AccessObjectProperties
See Also | AccessObject Object | CodeData Object | CurrentData Object