code for "filter by selection" button, etc.

  • Thread starter Thread starter Jerry Crosby
  • Start date Start date
J

Jerry Crosby

I'd like a button on a form that applies a "filter by selection" and another
to remove the filter (rather than to instruct the user to use the icon in
the toolbar).

Similiarly, I'd like buttons that mimic the sort ascending and sort
descending icons in the toolbar.

What's the code for those?

Jerry
 
From Jerry Crosby :
I'd like a button on a form that applies a "filter by selection" and another
to remove the filter (rather than to instruct the user to use the icon in the
toolbar).

Similiarly, I'd like buttons that mimic the sort ascending and sort
descending icons in the toolbar.

What's the code for those?

Jerry

No, I do not have the code for that but another way of doing those
actions is to create a custom menu (popup) and drag these actions from
the menu-actions to that menu. For example the Records menu has sorting
both ways, so add those two to your menu.
When finished, open the form where you want them in design mode and
assign that menu as the quickmenu (dunno if the naming is correct, I
have Access here in a different language). Anyway, using such a menu
you can add most items from the 'standard' menu's to a
right-mouse-button menu.
 
I'm trying your idea, but I'm still hopeful someone will know the coding I
could place behind a command button.

Jerry
 
You can send the form into FilterByForm mode with:
RunCommand acCmdFilterByForm

However, you can't get back from that mode with a command button, because NO
events fire in that view. As a result, it's probably better to train people
to use the Toolbar buttons rather than command buttons.

To remove a filter:
Me.FilterOn = False

You can sort by a particular field like this:
Me.OrderBy = "[Surname] DESC"
Me.OrderByOn = True
Omit the DESC for an ascending sort.

It's always worth explicitly saving the record before doing anything that
requires the record to save, such as applying or removing a filter or sort
order:
If Me.Dirty Then Me.Dirty = False
 
Back
Top