Others

Change the Search Field in a Microsoft Access Combo Box

Steve KSteve K Nov 25, 2026 868 views

Question details

Change a desktop Access form's search combo box to use a different field without triggering the copied macro's errors.

Change the Search Field in a Microsoft Access Combo Box
Product
Microsoft Access desktop database
Device & OS
not provided
Scenario
A user copies a search combo box and changes its Row Source to search a form by another field.
Observed behavior
The copied combo box triggers an object or class event error and a SearchForRecord macro error.
Before you start

Open the desktop database and identify the form's record source, its unique key field, and the field you want to display in the combo box. The example below assumes the form includes a unique numeric ID field.

Solution 1Recommended

Use VBA to find the selected record from the combo box

Replace the copied search macro with an After Update procedure that finds the selected key in the form's RecordsetClone.

This example displays customer names but searches by a numeric ID. Replace the table, field, and control names with those in your database. The form's record source must include the same unique ID as the combo box.

1
Open the form in Design View

In the Navigation Pane, right-click the form and select Design View. Select the copied combo box, then open its Property Sheet.

2
Configure the combo box

On the Data tab, leave Control Source blank and set Row Source to an example such as SELECT ID, CustomerName FROM Customers ORDER BY CustomerName;. On the Format tab, set Column Count to 2 and Column Widths to 0;2 to hide the ID and display the name. On the Data tab, set Bound Column to 1 so the combo box returns the ID.

3
Replace the copied event

On the Other tab, name the control cboFindCustomer. On the Event tab, set After Update to [Event Procedure], replacing the copied macro, and click the build button (...) to open the VBA editor.

4
Add the search procedure

In the form's VBA module, use this procedure, replacing ID and cboFindCustomer if your names differ: Private Sub cboFindCustomer_AfterUpdate() Dim rs As DAO.Recordset If IsNull(Me.cboFindCustomer.Value) Then Exit Sub Set rs = Me.RecordsetClone rs.FindFirst "[ID] = " & CLng(Me.cboFindCustomer.Value) If Not rs.NoMatch Then Me.Bookmark = rs.Bookmark rs.Close Set rs = Nothing End Sub

5
Compile and test

In the VBA editor, select Debug > Compile, then save the form and open it in Form View. Select a name from the combo box and confirm that the form moves to the corresponding record.

Use VBA to find the selected record from the combo box
Match the key and data type: The sample uses CLng for a numeric ID. A text key requires a properly quoted and escaped FindFirst criterion. If no record matches the current form recordset, the form stays on its current record.
Free Microsoft Office alternative

Work with Office documents in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with compatible Office documents, making it easier to move everyday document workflows. It does not fix Access macros or replace Access forms and VBA.

Open and edit compatible Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXReview exported Access data in a spreadsheetUse a familiar interface for everyday document tasksWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does the copied combo box still run the old search macro?

The copied control may retain its After Update macro. In Design View, select the combo box, open the Property Sheet's Event tab, and replace After Update with [Event Procedure].

Can the combo box show a name while searching by ID?

Yes. Include both fields in the Row Source, set Bound Column to the ID column, and use Column Widths to hide the ID. The displayed name helps the user select a record while the VBA searches by the bound ID.

Why doesn't the form move to the selected record?

Check that the combo box's Bound Column returns the same key included in the form's record source. Also check whether the form's current filter excludes the selected record; RecordsetClone searches the form's current recordset.

Can I reuse the search logic for several combo boxes?

Yes. Place suitable search logic in a shared VBA function and call it from each combo box's After Update procedure. Each call must use the correct control value, key field, and data type.