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()
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!