Table of contents
Collapse the table of content
Expand the table of content

AllViews Object (Access)

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

The AllViews collection contains an AccessObject for each view in the CurrentData or CodeData object.


The CurrentData or CodeData object has an AllViews collection containing AccessObject objects that describe instances of all views specified by CurrentData or CodeData. For example, you can enumerate the AllViews collection in Visual Basic to set or return the values of properties of individual AccessObject objects in the collection.

You can refer to an individual AccessObject object in the AllViews 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 AllViews collection, it's better to refer to the view by name because a view's collection index may change.

The AllViews collection is indexed beginning with zero. If you refer to a view by its index, the first view is AllViews(0), the second table is AllViews(1), and so on.



The following example prints the name of each open AccessObject object in the AllViews collection.

Sub AllViews() 
    Dim obj As AccessObject, dbs As Object 
    Set dbs = Application.CurrentData 
    ' Search for open AccessObject objects in AllViews collection. 
    For Each obj In dbs.AllViews 
        If obj.IsLoaded = True Then 
            ' Print name of obj. 
            Debug.Print obj.Name 
        End If 
    Next obj 
End Sub



See also

Other resources

Access Object Model Reference

© 2017 Microsoft