How to Change a Main Access Form Variable from a Subform (Error 2465)
Question details
The user needs to change a Boolean variable declared in a Microsoft Access main form from within a subform, but referencing the variable triggers Error 2465.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Updating a main form's variable state from a subform using VBA in Microsoft Access.
- Observed behavior
- Referencing the main form variable (e.g., Forms!AttnFormA.ChecksubEdits) from the subform produces runtime error 2465 because the variable is not publicly accessible.
Ensure your Microsoft Access main form remains open while the subform is active, as form variables are instantly destroyed in memory the moment a form is closed.
Declare the Variable as Public in the Main Form
The most direct way to allow a subform to modify a main form's variable is by changing its scope from a local dimension (Dim) to a Public variable.
Variables declared with 'Dim' inside a form's module are Private by default and cannot be seen by other forms, including subforms. Changing the declaration to 'Public' exposes it to the subform.
Open your Microsoft Access database, right-click your main form (e.g., AttnFormA) in the Navigation Pane, and select 'Design View'. Click 'View Code' in the Design tab to open the VBA Editor.
Locate the variable declaration at the top of the module. Change 'Dim ChecksubEdits As Boolean' to 'Public ChecksubEdits As Boolean'.
Open the VBA module for your subform. You can now safely assign a value to the variable using the syntax: Forms!AttnFormA.ChecksubEdits = True.

Use Public Property Procedures
For better encapsulation and to trigger specific code when the variable changes, use Public Property Let and Get procedures instead of a standard public variable.
Discover a Lightweight Microsoft Office Alternative
While Microsoft Access is designed for complex relational database management, WPS Office provides a free, highly efficient suite for your everyday document, spreadsheet, and presentation tasks. Enjoy maximum compatibility with Microsoft Office formats without the hefty subscription fees.
- 1. Visit the Official Site: Go to the official WPS Office website to find the latest free version.
- 2. Download the Installer: Click the Free Download button corresponding to your Windows, Mac, or Linux operating system.
- 3. Install and Open: Run the lightweight installer. Once finished, you can instantly open and edit your existing Microsoft Office files.

Frequently Asked Questions
What does Microsoft Access Error 2465 mean?
Error 2465 typically states 'Microsoft Access can't find the field referred to in your expression.' This occurs when you try to reference a variable, control, or field that is out of scope, misspelled, or declared as Private in another form's module.
Can I use Me.Parent to reference the main form from a subform?
Yes, Me.Parent is a reliable and dynamic way to reference the main form from a subform's VBA module. For example, Me.Parent.YourPublicVariable will access a public variable on the parent form without needing to hardcode the main form's exact name.
Why does my main form variable reset or become unavailable?
Form-level variables only exist in memory while the form is actively open. If the main form is closed, or if an unhandled VBA runtime error forces the project to reset, the variable's value will be wiped out and referencing it will cause an error.




