Smart questions
Smart answers
Smart people
Join Tek-Tips Forums
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Microsoft: Access Forms FAQ

Calendars

Keep getting Error 2501?
Posted: 25 Oct 02 (Edited 25 Oct 02)

Having seen a number of people asking about Error 2501.

This Access error says:

"The OpenForm action was cancelled"
"You used a method of the DoCmd object in Visual Basic, but then clicked Cancel in a dialog box"


It normally occurs when you try to open a form in Visual Basic using the DoCmd.OpenForm statement.

The main problem is what is tells you is not necessarily true! You don't have to click Cancel in a dialog box for the error to occur.

One of the main reasons for the error is trying to open a form with incorrect Visual Basic behind it. For example,

If I try to open frmSecond from frmFirst using: DoCmd.OpenForm "frmSecond" somewhere in the code module of frmFirst, but I have accidentally typed the following code somewhere in the code module of frmSecond:


Private Sub btnMyButton_Click()
Private Sub btnMyButton_Click()

...

End Sub


The call to DoCmd.OpenForm "frmSecond" causes Error 2501, as the Visual Basic error I have caused by writing Private Sub btnMyButton_Click() twice in frmSecond prevented the form from opening.

You didn't click Cancel, but Access effectively did! When opening the form, Access checks that the Visual Basic is correct. If it's not, the form won't open, causing Error 2501.

An easy way to check that this is your cause, is to open the form (i.e. frmSecond above) manually and see if it'll open. If you can't open it, chances are Access can't either!

Back to Microsoft: Access Forms FAQ Index
Back to Microsoft: Access Forms Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close