Others

Add an Access Form Button to Open the Filter Menu

Adam DavisAdam Davis Nov 25, 2026 868 views

Question details

Add a button to an Access form that opens the standard filter menu and restrict favorite records to the current user.

Add an Access Form Button to Open the Filter Menu
Product
Microsoft Access
Device & OS
not provided
Scenario
A form lets users select a user code and work with favorite records; the user also wants a button to open the filter menu.
Observed behavior
The filter menu needs the relevant control to have focus, and filtering favorites alone shows records for all users.
Before you start

Open the form in Design View and identify the control to filter, the user ID control, and the field names in the form's record source. Confirm whether UserID is numeric or text, since the filter expression depends on its data type.

Solution 1Recommended

Set focus before opening the Access filter menu

Use this approach when a form button should open the standard filter menu for a specific control.

1
Add a command button

Open the form in Design View, add a Button from the Design tab, and select the new button.

2
Open the click event

In the Property Sheet, select the Event tab, set On Click to [Event Procedure], and click the ellipsis button to open the VBA editor.

3
Set focus and run the command

In the button's Click procedure, add `Me!YourControlName.SetFocus` followed by `DoCmd.RunCommand acCmdFilterMenu`. Replace `YourControlName` with the name of the control whose filter menu you want to open.

4
Test the button

Save the form, switch to Form View, and click the button. Confirm that the control can receive focus and that the filter command is available in the current view.

Set focus before opening the Access filter menu
Use the previously focused control: If the button should act on the control used immediately before it was clicked, use `Screen.PreviousControl.SetFocus` instead of naming a control. This requires a suitable previous control that can receive focus.
Free Microsoft Office alternative

Manage Related Spreadsheet Data with WPS Office

WPS Office is a free, lightweight alternative for everyday office work, with a familiar interface and compatibility with common Microsoft Office files for a smoother transition. Use WPS Spreadsheets to filter tabular data; it does not replace Access forms or fix Access VBA commands.

Filter spreadsheet rows by user or favorite statusOpen and edit Microsoft Excel XLSX filesUse a familiar interface for common office tasksWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why doesn't the filter menu open when I click the button?

The button may have focus instead of the field to filter. In the button's On Click event, call `SetFocus` on the relevant control before running `DoCmd.RunCommand acCmdFilterMenu`. Also check that filtering is available in the current form view.

How do I show favorites for just one user?

Set the form's Filter property to combine the Favorite and UserID conditions with AND, then set FilterOn to True. Ensure both fields are available in the form's record source.

What if UserID is a text field?

Text criteria need quotes around the value. In the VBA filter expression, surround the ID with single quotes and escape any embedded apostrophes, for example with `Replace(Me!cboUserID.Value, "'", "''")`.

How should I store favorites shared across many users and items?

Use a linking table containing user IDs and item IDs for the many-to-many relationship. In the form's record source, join that table to the user and item tables as needed, then filter on the linking table's user ID.