Fix Access Report On Print and Report Load Events Errors
Question details
The user needs to resolve issues where Microsoft Access report event procedures fail to execute, causing expression and variable errors during report loading or print preview.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Troubleshooting failing event procedures, unverified variables, and broken page-numbering expressions when opening or previewing an Access database report.
- Observed behavior
- Event procedures (like On Print and On Load) do not run, Print Preview displays a variable-not-defined error, and page-number text boxes show a #Name? error.
Before making changes to the VBA modules or report properties, create a backup copy of your Access database file (.accdb or .mdb) to ensure your existing data and forms remain safe.
Rebind Event Procedures in Design View
Ensure that the report's properties are correctly connected to the VBA event procedures to allow them to trigger properly.
Often, report events fail to run because the property sheet is blank rather than pointing to the actual VBA code block. Re-establishing this link usually restores functionality.
Open your Access database, locate the problematic report in the navigation pane, right-click it, and select Design View.
Select the entire report or the specific section you want to modify. Press F4 to open the Property Sheet on the right side of your screen.
Navigate to the Event tab in the Property Sheet. Locate the 'On Load' and 'On Print' fields, click the drop-down arrow, and select [Event Procedure].
Click the Build button (...) next to [Event Procedure] to open the VBA editor. Ensure that the procedure names perfectly match the expected event properties for that report.

Resolve Naming Conflicts and Variable Errors
Fix variable-not-defined errors by auditing module declarations and identifying conflicting control names.
Fix the Page Number #Name? Error
Correct the syntax inside the text box control source to properly display report page numbers without errors.
Looking for a lighter Office suite? Try WPS Office
While WPS Office does not include a database management tool like Microsoft Access, it offers a highly compatible, free, and lightweight alternative for all your Word, Excel, and PowerPoint tasks. Enjoy a familiar tabbed interface and seamless file compatibility without expensive subscription fees.
- 1. Download the Installer: Visit the official WPS Office website and download the free version for your operating system.
- 2. Install the Software: Run the installer file and follow the quick setup wizard to install the suite on your computer.
- 3. Open Your Documents: Launch WPS Office and open your existing docx, xlsx, or pptx files directly with full formatting preserved.

Frequently Asked Questions
Why do I get a 'variable not defined' error in my Microsoft Access report?
This error occurs when a VBA script references a variable, object, or control name that does not exist, is misspelled, or is out of scope. Compiling the code in the VBA editor can help you quickly locate and define the missing variable.
What causes a #Name? error on an Access report page number?
The #Name? error appears when Access cannot evaluate an expression in a control's Control Source property. For page numbers, it usually means the syntax is incorrect. Ensure you are using exactly ="Page " & [Page] & " of " & [Pages].
What is the difference between On Load and On Print events in Access?
The On Load event triggers once when a report is first opened, making it best for initializing global variables or settings. The On Print event triggers just before a section's data is formatted for the printer, which is useful for calculating running totals.
Does WPS Office have a database alternative to Microsoft Access?
WPS Office is primarily designed for document creation, spreadsheet analysis, and presentations (similar to Word, Excel, and PowerPoint). It does not currently feature a relational database management program equivalent to Microsoft Access.




