AllDataAccessPages Collection

Microsoft Access Visual Basic

AllDataAccessPages Collection

         
Multiple objects AllDataAccessPages
AccessObject

The AllDataAccessPages collection contains an AccessObject object for each data access page in the CurrentProject or CodeProject object.

Note   Although a Microsoft Access project (.adp) or Microsoft Access database (.mdb) can appear to contain data access pages, these pages are actually stored in files that are external to the project or database.

Using the AllDataAccessPages Collection

The CurrentProject or CodeProject object has an AllDataAccessPages collection containing AccessObject objects that describe instances of all data access pages. For example, you can enumerate the AllDataAccessPages collection in Visual Basic to set or return the values of properties of individual AccessObject objects in the collection.

Tip   The For Each...Next statement is useful for enumerating a collection.

You can refer to an individual AccessObject object in the AllDataAccessPages collection either by referring to the item by name, or by referring to its index within the collection. If you want to refer to a specific data access page in the AllDataAccessPages collection, it's better to refer to the item by name because the index may change.

The AllDataAccessPages collection is indexed beginning with zero. If you refer to a data access page by its index, the first data access page is AllDataAccessPages(0), the second data access page is AllDataAccessPages(1), and so on.

Note   To list all open data access pages in the database, use the IsLoaded property of each AccessObject object in the AllDataAccessPages collection. You can then use the Name property of each individual AccessObject object to return the name of a data access page.

You can't add or delete an AccessObject object from the AllDataAccessPages collection.

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

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