Fix a Microsoft Access OpenForm Error and Open the Matching Record
Question details
Open an Access form at the record matching the value on the current form and investigate an Automation object Form error.

- 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.
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.
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.
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.
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], "'", "''") & "'"
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.

Add a Where Condition to an Embedded OpenForm Macro
Use this approach if you want to retain the embedded macro rather than switch to VBA.
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.

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.




