VBA & Macro Problems

Fix a Microsoft Access OpenForm Error and Open the Matching Record

Natalie TaylorNatalie Taylor Nov 18, 2026 868 views

Question details

Open an Access form at the record matching the value on the current form and investigate an Automation object Form error.

Fix a Microsoft Access OpenForm Error and Open the Matching Record
Product
Microsoft Access
Device & OS
not provided
Scenario
A form-opening action should display the record whose Generic Tour Name matches the current form.
Observed behavior
The destination form opens the first record instead of the matching record, and an Automation object Form error is reported.
Before you start

Identify the source form, destination form, and matching field or control names. Confirm that Generic Tour Name is a text field in the destination form's record source and that the source form is open when the action runs.

Solution 1Recommended

Open the Matching Access Record with a VBA WhereCondition

Use an event procedure to pass the current form's text value to OpenForm as a filter.

A WhereCondition controls which record the destination form displays. It may not resolve an Automation object error caused by a separate reference or expression problem.

1
Open the event procedure

Open the source form in Design view, select the button or control that opens the destination form, and open its Property Sheet. On the Event tab, select the relevant event, click the build button, and choose Code Builder.

2
Add the filter

Between the existing procedure lines, enter: If IsNull(Me.[Generic Tour Name]) Then MsgBox "Select a tour name first." Exit Sub End If DoCmd.OpenForm "NameOfForm", WhereCondition:="[Generic Tour Name] = '" & Replace(Me.[Generic Tour Name], "'", "''") & "'"

3
Adjust and test

Replace NameOfForm and Generic Tour Name with your actual form, field, and control names. Save the procedure, open the source form in Form view, select a record, and activate the control.

Open the Matching Access Record with a VBA WhereCondition
How the filter works: Me refers to the current form. The example is for a text field and escapes apostrophes in its value. If multiple destination records have the same name, the filter can return more than one record.
Free Microsoft Office alternative

Work with Office Files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with documents, spreadsheets, and presentations. Its Microsoft Office format compatibility makes it easy to move everyday files, although it does not fix Access Automation errors or replace Access forms and macros.

Work with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTX.Use a familiar interface for everyday Office tasks.Open and edit spreadsheets alongside your Access-related work.Get a free, lightweight suite for common document tasks.
microsoft office alternative - wps office

Frequently Asked Questions

Why does OpenForm show the first record?

Without a WhereCondition or Where Condition, Access opens the form without a filter for the current value. Add a condition that compares the destination field with the value on the source form.

What does Me mean in the VBA example?

Me refers to the form whose event procedure is running. Me.[Generic Tour Name] reads the named control or field from that current form.

Will the WhereCondition fix every Automation object Form error?

No. The condition fixes the record-selection logic when it is set correctly. If the Automation error remains, inspect the failing expression or VBA line and check Tools > References in the VBA editor for missing references.

What if more than one record has the same tour name?

The condition can return all records with that name. If you need exactly one record, use a unique field such as a record ID in the OpenForm condition instead.