Others

How to Change a Main Access Form Variable from a Subform (Error 2465)

John WilsonJohn Wilson Nov 2, 2026 869 views

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.

How to Change a Main Access Form Variable from a Subform
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the Main Form Module

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.

2
Change Dim to Public

Locate the variable declaration at the top of the module. Change 'Dim ChecksubEdits As Boolean' to 'Public ChecksubEdits As Boolean'.

3
Reference from the Subform

Open the VBA module for your subform. You can now safely assign a value to the variable using the syntax: Forms!AttnFormA.ChecksubEdits = True.

Declare the Variable as Public in the Main Form
Use Me.Parent Shortcut: Instead of hardcoding the main form's name, you can use Me.Parent.ChecksubEdits = True in the subform to dynamically reference the parent form.
Free Microsoft Office alternative

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. 1. Visit the Official Site: Go to the official WPS Office website to find the latest free version.
  2. 2. Download the Installer: Click the Free Download button corresponding to your Windows, Mac, or Linux operating system.
  3. 3. Install and Open: Run the lightweight installer. Once finished, you can instantly open and edit your existing Microsoft Office files.
Fully compatible with Microsoft Word, Excel, and PowerPoint formats (.docx, .xlsx, .pptx).Seamlessly handle complex data analysis using WPS Spreadsheet as an alternative to Excel.Lightweight installation that runs smoothly on older devices and saves system resources.Free to use with a familiar, easy-to-navigate tabbed interface.
microsoft office alternative - wps office

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.