How to Fix Microsoft Access Runtime Error: OpenForm Action Was Canceled
Question details
The user is experiencing an 'OpenForm action was canceled' runtime error when attempting to open a dashboard form from a login form using VBA in Microsoft Access.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Opening a dashboard form using VBA after completing a login procedure.
- Observed behavior
- The OpenForm action fails and is canceled, preventing the destination dashboard form from opening as intended.
Ensure you have access to the VBA editor in your Microsoft Access database and create a backup of your database file before making any modifications to the form's code.
Inspect and Modify the Dashboard Form Event Code
Identify and resolve code blocks in the target form that might be intentionally or accidentally canceling the form opening process.
Often, the error is not located in the login form's code, but rather in the destination (Dashboard) form. If the destination form has validation failures, contains runtime-incompatible code, or explicitly sets the Cancel parameter to True during its initialization, the OpenForm action will fail.
Right-click the Dashboard form in the Access Navigation Pane, select 'Design View', and then click 'View Code' from the Design tab in the ribbon.
Locate the 'Private Sub Form_Open(Cancel As Integer)' procedure. Check if there are any conditions, validation checks, or statements that execute 'Cancel = True'.
To isolate the issue, type an apostrophe (') before the lines of code in the Form_Open and Form_Load events to temporarily comment them out. Save your changes and try opening the form again.
If the form opens successfully after commenting out the code, review the disabled lines to find runtime-incompatible operations and rewrite the failing procedure to ensure it functions correctly.

Looking for a Free and Lightweight Office Alternative?
While Microsoft Access handles complex database management, WPS Office provides an excellent, free alternative for your daily document, spreadsheet, and presentation tasks. It offers high compatibility with Microsoft Office formats without the hefty subscription fees.
- 1. Download the Installer: Visit the official WPS Office website and click the free download button.
- 2. Install WPS Office: Run the downloaded installation file and follow the on-screen instructions to set up the software.
- 3. Open Your Documents: Launch WPS Office and easily open or edit your existing Microsoft Office files with full format retention.

Frequently Asked Questions
Why does the OpenForm action get canceled in Access VBA?
This usually occurs because the VBA code within the target form's Form_Open or Form_Load events explicitly halts the opening process (e.g., setting 'Cancel = True'), or the form encounters an unexpected validation failure or runtime error.
How do I find the code that is causing the OpenForm error?
You need to open the Access database in Design View, access the VBA Editor by clicking 'View Code', and specifically inspect the event procedures of the target form you are trying to open, rather than just checking the form that triggered the action.
Will this error occur if my database is run in Access Runtime?
Yes. Some VBA methods and operations are not allowed in the restricted Access Runtime environment. If the target form contains incompatible code, the operation will fail and cancel the form opening.




