Change the Search Field in a Microsoft Access Combo Box
Question details
Change a desktop Access form's search combo box to use a different field without triggering the copied macro's errors.

- 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.
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.
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.
In the Navigation Pane, right-click the form and select Design View. Select the copied combo box, then open its Property Sheet.
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.
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.
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
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.

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.

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.




