Code Examples For RunCommand Constants

Add New Records

acCmdDataEntry, acCmdRemoveFilterSort

This code goes behind a Command Button called cmdDataEntry. It changes a form from an edit form into a data entry form and vice versa.

'***************** Code Start *******************
' Original code by Tery Wickenden

Private Sub cmdDataEntry_Click()

  Dim ctl As CommandButton

  Set ctl = Me.cmdDataEntry
  Select Case ctl.Caption
    Case "Add New Records"
      DoCmd.RunCommand acCmdDataEntry
      ctl.Caption = "Show All Records"
    Case "Show All Records"
      DoCmd.RunCommand acCmdRemoveFilterSort
      ctl.Caption = "Add New Records"
  End Select
  Set ctl = Nothing

End Sub

'****************** Code End ********************