Code Examples

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 ********************

© 1998 - 2011 Terry Wickenden TKW Design Site developed maintained and hosted by TKW Design. This site is best viewed at 1024 x 768. Optimised for Firefox.