Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run time error: '2501'

Status
Not open for further replies.

GelC

Technical User
Oct 3, 2006
93
0
0
US
I have a button to run command edit hyperlink.
When I click "Cancel", I keep getting...
Run-time error '2501':
The RunCommand was canceled.

How can I get rid of it?
Thanks for any help!

GelC
 
Use an Error handler.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Is there anything wrong in the following code?
Code:
Private Sub cmdEditLink_Click()
  'Opens hyperlink dialog
  On Error GoTo ErrEditHyper
  Me.ViewDoc.SetFocus
  DoCmd.RunCommand acCmdEditHyperlink
  Exit Sub
ErrEditHyper:
  Select Case Err
    Case 2046
      'Edit Hyperlink not available
      MsgBox "You must be in a hyperlink field.", vbCritical, "Error Message"
      Resume Next
    Case 2501
      'Cancel button selected do nothing
      Resume Next
    Case Else
      MsgBox Err & vbCrLf & vbCrLf & Err.Description, vbCritical, "Error Message"
      Resume Next
  End Select
End Sub
 
Did you ever figure this out GelC? I have similar code to trap 2501 when user cancels from Edit Hyperlink pop-up and I continue to get 2501 message.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top