Others

How to Hide a Control on an Access Subform Based on a Condition

Adam DavisAdam Davis Nov 2, 2026 869 views

Question details

The user needs to dynamically hide a control located on a Microsoft Access subform based on a specific condition, but encounters an Automation object error when using a macro reference.

How to Hide a Control on an Access Subform Based on a Condition
Product
Microsoft Access
Device & OS
not provided
Scenario
Setting up conditional visibility for a control inside a subform.
Observed behavior
A macro referencing the subform control throws an Automation object error because the syntax used to target the subform control is incorrect.
Before you start

Verify the exact name of the subform control as it appears on your main form, which may be different from the actual name of the embedded form object in the navigation pane.

Solution 1Recommended

Use Correct Subform Referencing Syntax in the On Load Event

Resolve the Automation object error by using the proper relative addressing syntax to reference the subform control container on the main form.

When working with subforms in Microsoft Access, you must reference the subform control container situated on the main form, rather than the source form object itself. Incorrect referencing is the most common cause of Automation object errors in this scenario.

1
Open the Main Form in Design View

Right-click your main form in the Navigation Pane and select Design View.

2
Identify the Subform Control Name

Click once on the subform control container on your main form. Open the Property Sheet (F4) and check the 'Name' property on the Other tab to confirm its exact name.

3
Locate the On Load Event

Click the form selector (the square in the upper-left corner of the main form or subform depending on where your logic applies). In the Property Sheet, navigate to the Event tab and find the 'On Load' event. Do not use the 'On Open' event.

4
Apply the Conditional Logic

Click the ellipsis (...) next to the On Load event to open the Code Builder or Macro Builder. Enter your logic using the correct syntax: Forms!MainFormName!SubformControlName.Form!ControlName.Visible = False (or True).

Use Correct Subform Referencing Syntax in the On Load Event
Alternative Syntax Options: You can also use dot notation to reference the control: Forms!formname!subformname.Form.Controlname.
Free Microsoft Office alternative

Looking for a Lightweight, Everyday Office Suite?

While WPS Office does not feature a direct database alternative to Microsoft Access, it serves as a highly efficient, free alternative for your daily document, spreadsheet, and presentation workflows. Enjoy a familiar interface and comprehensive format compatibility.

  1. 1. Download the Installer: Visit the official WPS Office website and click the Free Download button for your operating system.
  2. 2. Install the Software: Run the downloaded executable file and follow the straightforward on-screen instructions.
  3. 3. Start Creating: Launch WPS Office to easily create, edit, and manage your files without expensive subscriptions.
Fully compatible with Microsoft Office formats including .docx, .xlsx, and .pptx.Lightweight installation with blazing fast loading times.All-in-one suite combining documents, spreadsheets, presentations, and PDFs in a single tabbed interface.
microsoft office alternative - wps office

Frequently Asked Questions

Why do I get an Automation object error when referencing an Access subform?

This usually happens when your macro or VBA code targets the name of the form object directly instead of targeting the subform control container that physically resides on the main form.

Should I use the On Open or On Load event to hide controls conditionally?

You should use the On Load event. The On Open event fires before the form's data is fully loaded into the controls, meaning control values required to evaluate your condition may not be accessible yet.

How do I find the correct name of my subform control?

Open your main form in Design View, click once on the subform area to select the container (ensure you don't click twice, which selects the form inside it), and check the 'Name' property listed in the Property Sheet under the Other tab.