Skip to content
Auscultby NBIT
EN
Free diagnostic

Access error reference

Access runtime error 2501: “The OpenForm action was canceled.”

“The OpenReport action was canceled” is not always a fault. Access is saying that an action started by the code did not complete — often because the application wanted it that way, sometimes because a choice was missing.

The message

The OpenForm action was canceled.

English Access; the action name varies: OpenReport, OutputTo, OpenQuery, RunSQL, Close, DoMenuItem…

On a French Access: « L'action OpenForm a été annulée. » (VBA: “Run-time error '2501': …”).

Where it shows up

On a DoCmd call: DoCmd.OpenReport, DoCmd.OpenForm, DoCmd.OutputTo, DoCmd.RunSQL, DoCmd.Close.

Common causes

  • a report with no data whose On No Data event sets Cancel = True: the code that opened it gets 2501;
  • a form that refuses to open (Cancel = True in On Open) because a prior choice or permission is missing;
  • the user cancels a print dialog, a file save dialog (OutputTo) or an action-query confirmation;
  • an argument the action cannot use.

How to reproduce and check it

  1. Note the action quoted and the object it opens.
  2. Open that object on its own: a “no data” message or an immediate close points to its open event.
  3. Try again after making the expected choice (customer selected, dates filled in): if the error goes away, it is the case the application planned for.

How to fix it

When the cancellation is intended, trap it in the calling code: On Error GoTo ErrHandler … ErrHandler: If Err.Number = 2501 Then Resume Next. Otherwise fix what causes it: tell the user a choice is missing instead of opening an empty report.

What Auscult reports

The diagnostic treats 2501 as an error to confirm, not as an automatic fault: “Access interrupted the action: the application canceled it itself, often because a prior choice was missing.” When the form or report is not meant to be opened on its own, it is marked “to check”, with the instruction to replay the action by hand under normal conditions of use.

The Access error reference, code by code

Frequently asked questions

Can I just ignore error 2501?

In the calling code, yes, when the cancellation is expected (report with no data). But check it is intended first: a cancellation hiding a missing choice deserves a clear message to the user.

Where are the other errors in your application hiding?

The diagnostic runs on your computer, on a copy of the application, without sending the data in your tables. The health grade and the summary are free.