DataAccessPage Object, DataAccessPages Collection Example

The following example creates a new data access page and sets certain properties:

Sub NewDataAccessPage()
    Dim dap As DataAccessPage
    ' Create new data access page.
    Set dap = CreateDataAccessPage("c:\My Documents\Sales Entry", _
            True) 
    ' Set data access page Tag property.
    dap.Tag = "Sales Entry Data Access Page"
    ' Restore data access page.
    DoCmd.Restore
End Sub

The next example enumerates the DataAccessPages collection and prints the name of each data access page in the DataAccessPages collection.

Sub AllOpenDataAccessPages()
    Dim dap As DataAccessPage

    Set dbs = Application.CurrentProject
    ' Search for open objects in DataAccessPages collection.
    For Each dap In dbs.AllDataAccessPages
        If dap.IsLoaded = TRUE then
            ' Print name of form.
            Debug.Print dap.Name
        End If
    Next dap
End Sub