This documentation is archived and is not being maintained.

CurrentView Property [Access 2003 VBA Language Reference]

Office 2003

AcCurrentView can be one of these AcCurrentView constants.
acCurViewDatasheet
acCurViewDesign
acCurViewFormBrowse
acCurViewPivotChart
acCurViewPivotTable
acCurViewPreview

expression.CurrentView

expression Required. An expression that returns an AccessObject object.

You can use the CurrentView property to determine how a data access page is currently displayed. Read-only Integer.

expression.CurrentView

expression Required. An expression that returns a DataAccessPage object.

You can use the CurrentView property to determine how a form is currently displayed. Read/write Integer.

expression.CurrentView

expression Required. An expression that returns a Form object.

Settings

The CurrentView property uses the following settings.

Setting Form Displayed In: Data Access Page Displayed In:
0 Design view Design view
1 Form view Page view
2 Datasheet view Not applicable

Note  This property is available only by using a macro or Visual Basic and is read-only in all views.

Remarks

Use this property to perform different tasks depending on the current view. For example, an event procedure could determine which view the form is displayed in and perform one task if the form is displayed in Form view or another task if it's displayed in Datasheet view.

Example

The following example uses the GetCurrentView subroutine to determine whether a form is in Form or Datasheet view. If it's in Form view, a message to the user is displayed in a text box on the form; if it's in Datasheet view, the same message is displayed in a message box.

GetCurrentView Me, "Please contact system administrator."

Sub GetCurrentView(frm As Form, strDisplayMsg As String)
    Const conFormView = 1
    Const conDataSheet = 2
    Dim intView As Integer
    intView = frm.CurrentView
    Select Case intView
        Case conFormView
            frm!MessageTextBox.SetFocus
            ' Display message in text box.
            frm!MessageTextBox = strDisplayMsg
        Case conDataSheet
            ' Display message in message box.
            MsgBox strDisplayMsg
    End Select
End Sub
		




Show: