logo
search
Others

How to Open a Selected Contact Record from an Access Subform

Phi Hung VoPhi Hung Vo Oct 19, 2026 869 views

Question details

The user wants to open a specific contact record by double-clicking it in an Access subform but encounters a 'Method or data member not found' compile error.

How to Open a Selected Contact Record from an Access Subform
Product
Microsoft Access
Device & OS
not provided
Scenario
Triggering a VBA event to open a related form based on a selected record in a subform.
Observed behavior
A compile error occurs referencing the CustID# field, preventing the Contacts form from opening.
Before you start

Verify that the fields you are referencing in your VBA code exist as controls on your subform and that the target form is correctly named in your database.

Solution 1Recommended

Bind the Event to the Specific Control Rather than the Subform

Attach the double-click event directly to the ContactID control instead of the entire subform to accurately target the selected record.

Applying the double-click event to the entire subform can lead to unexpected behaviors or reference errors. Binding the event specifically to the unique identifier control ensures that the command executes exactly on the row the user clicked.

1
Open Subform in Design View

Open your Microsoft Access database, right-click the contacts subform in the Navigation Pane, and select Design View.

2
Access Control Properties

Right-click the ContactID text box control (not the form background) and select Properties to open the Property Sheet.

3
Add Event Procedure

Navigate to the Event tab on the Property Sheet, click on the On Dbl Click property, select [Event Procedure] from the dropdown, and click the ellipsis (...) button.

4
Insert VBA Code

In the VBA editor, enter the following command: DoCmd.OpenForm FormName:="Contacts", WhereCondition:="ContactID = " & Me.ContactID

5
Save and Test

Save your form, switch to Form View, and double-click the ContactID field to ensure the targeted Contacts form opens correctly.

Bind the Event to the Specific Control Rather than the Subform
Free Microsoft Office alternative

Manage Your Data with WPS Office

While Microsoft Access handles complex relational databases, many users find that managing contacts and customer lists is much easier in a spreadsheet environment. WPS Office provides a free, lightweight, and highly compatible alternative for your daily data management needs without the hassle of complex VBA coding.

  1. 1. Download WPS Office: Download and install the WPS Office suite for free from the official website.
  2. 2. Open WPS Spreadsheet: Launch WPS Spreadsheet and create a new workbook for your data.
  3. 3. Import Your Data: Easily import your existing contact lists from CSV or Excel formats to start managing your records without complex databases.
Fully compatible with Microsoft Excel (.xlsx), Word (.docx), and PowerPoint formats.100% free and lightweight, ensuring smooth performance even on older computers.Familiar user interface makes migrating your contact lists and spreadsheets effortless.
microsoft office alternative - wps office

Frequently Asked Questions

Why do I get a 'Method or data member not found' error in Access VBA?

This compile error usually occurs when your VBA code references a field or control that does not exist on the current form. It can also happen if the referenced field name contains a special character, causing the VBA compiler to misinterpret the reference.

Are special characters allowed in Microsoft Access field names?

While Microsoft Access does technically allow characters like the pound sign (#) in field names, it is highly discouraged. Special characters can cause syntax errors in VBA modules and SQL queries unless explicitly wrapped in square brackets (e.g., [CustID#]).

How do I filter an Access form to a specific record via VBA?

You can use the DoCmd.OpenForm method combined with the WhereCondition parameter. For example, supplying WhereCondition:="ContactID = " & Me.ContactID instructs Access to open the target form filtered exclusively to the record that matches the selected ID.