Code Examples For RunCommand Constants

Open Replace Dialog

acCmdReplace

This code returns the cursor to the previous control and opens the Replace Dialog box. It assumes that the command button is called cmdReplace.

'***************** Code Start *******************
' Code by Terry Wickenden

Private Sub cmdReplace_Click()

  On Error GoTo ErrReplace

  Screen.PreviousControl.SetFocus
  DoCmd.RunCommand acCmdReplace
  Exit Sub

ErrReplace:

  Select Case Err
    Case 2046
      'Command not available
      MsgBox "Replace is not available at this time.", vbCritical, "Not Available"
    Case Else
      MsgBox Err.Number & ":-" & vbCrLf & Err.Description
  End Select

End Sub

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