Access.Form.Currentview write protected RRS feed

  • Question

  • The form is supposed to shift between form view and datasheet view. On the form is a CommandButton 'cmdDatasheetView' calling a VBA procedure in the forms code module.

    Private Sub cmdDatasheetView_Click()
        Const intcDatasheetView As Integer = 2
        Me.CurrentView = intcDatasheetView
    End Sub

    Executing the sub return an error message: Run-time error '2135': This property is write protected and can't be specified.

    According to online documentation CurrentView is read/write integer. Apparently there is no Form property setting a write protection.

    Is it possible to set CurrentView using VBA? If so, how?

    Monday, March 16, 2020 8:17 AM


  • That is an error in the documentation. Instead, use:

    RunCommand acCmdDatasheetView


    RunCommand acCmdFormView


    RunCommand acCmdLayoutView

    depending on which view you want to activate.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by MartinAnd67 Monday, March 16, 2020 10:23 AM
    Monday, March 16, 2020 10:04 AM