AllQueries object (Access)

The AllQueries collection contains an AccessObject for each query in the CurrentData or CodeData object.

Remarks

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.

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.

Note

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.

Example

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

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.