Filter by Selection

naterook

New member
Local time
Today, 14:50
Joined
Jul 8, 2022
Messages
15
Hi everyone.

Is there a way to create a Macro to filter by selection? I know there's a button in the ribbon, but some of our users are on RunTime and don't have the ribbon. In a form, I just need them to be able to Filter by Selection.

Thanks in advance.
 
you can try to add a button and on the Click event of the button, run the filterBySelection.
Code:
Private Sub Button1_Click()
Me.TextboxToFilter.SetFocus
DoCmd.RunCommand acCmdFilterBySelection
End Sub
 
You can add the right-click menu as a custom menu that works in runtime, no point in re-inventing the wheel?
 
You can add the right-click menu as a custom menu that works in runtime, no point in re-inventing the wheel?
That sounds like the simplest option... sorry, I'm super green here. Is that a form-level thing I need to change? How do I do that?
 
you can try to add a button and on the Click event of the button, run the filterBySelection.
Code:
Private Sub Button1_Click()
Me.TextboxToFilter.SetFocus
DoCmd.RunCommand acCmdFilterBySelection
End Sub
Thanks for this. VBA is new to me. Do I just drop this in the On Click area or do I need to substitute text? For example, on Private Sub Button 1_Click() do I need to change Button 1 to the name of my button?
 
bring your Form in Design view.
add a Command button (name it cmdFilterBySelection)
on it's Property->Event->On Click, choose "Code Builder", write the Code
inside the event.

you also need to add another button the Remove the filter:

private sub another_button_Click()
DoCmd.ShowAllRecords
end sub
 
bring your Form in Design view.
add a Command button (name it cmdFilterBySelection)
on it's Property->Event->On Click, choose "Code Builder", write the Code
inside the event.

you also need to add another button the Remove the filter:

private sub another_button_Click()
DoCmd.ShowAllRecords
end sub
arnelgp, you are fabulous! It works!
Thank you so much!!
 
question is... is there a right-click on Runtime?
Not intrinsically (the right-click menus are disabled), but you can use a shortcut menu to effectively reinstate the functionality.
 

Users who are viewing this thread

Back
Top Bottom