Open a Microsoft Access Form from a List Box Selection
Question details
Open an Access form to the record selected in a list box, using either a numeric ID or a text field as the filter.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A user selects an item in a list box and wants to display its matching record on another form.
- Observed behavior
- The target form should open with a filter that matches the selected list box value to the appropriate field.
Check the list box's Bound Column and Row Source in its Property Sheet, and confirm that the target form's Record Source contains the field you want to filter. Replace the example control, field, and form names with the names in your database.
Open the form using the selected numeric ID
Use the list box's bound ID to find the matching record without relying on a potentially duplicated name.
Open the source form in Design View, select the list box, and open Property Sheet > Data. Set Bound Column to the column containing StrainID, and verify that the target form's Record Source includes the same numeric field.
On the list box's Property Sheet, open the Event tab. Next to After Update, choose [Event Procedure] and select the ellipsis button to open the VBA editor.
Inside the event procedure, enter: If Not IsNull(Me!lboStrain.Value) Then DoCmd.OpenForm "frmStrain", WhereCondition:="[StrainID] = " & Me!lboStrain.Value End If
Save the form, switch to Form View, and select a list box item. Confirm that frmStrain opens to the record with the selected StrainID.

Open the form using a selected text value
Use this method when the list box is bound to StrainName and the target form has a matching text field.
Work with exported Access data in WPS Office
WPS Office is a free, lightweight alternative for working with office files in a familiar interface. Export Access data to Excel to review it in WPS Spreadsheets. WPS does not run Access forms or fix Access VBA, so keep using Access for this form workflow.

Frequently Asked Questions
Why does Access report a data type mismatch in the filter?
The filter may be comparing a numeric field with text or a text field with an unquoted value. Check the list box's Bound Column under Property Sheet > Data and use a field of the same data type in the target form's Record Source.
Can the list box show a name but use the ID to open the form?
Yes. Include both fields in the list box's Row Source, set Bound Column to the ID column, and adjust Column Widths in the Property Sheet to hide the ID if desired. The displayed name can then differ from the numeric value used in the filter.
What if a strain name contains an apostrophe?
A text criterion must escape apostrophes within the value. The text solution uses Replace to double each apostrophe before passing the criterion to DoCmd.OpenForm.
Why does the form show more than one matching record?
A text field such as StrainName may contain duplicates. Use a unique StrainID as the list box's bound value and filter the target form on that numeric field.




