code for "filter by selection" button, etc.

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
 
G

Gijs Beukenoot

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.
 
J

Jerry Crosby

I'm trying your idea, but I'm still hopeful someone will know the coding I
could place behind a command button.

Jerry
 
A

Allen Browne

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
 
J

Jerry Crosby

Thanks, Alan. I can stick with the toolbar option and it will work fine.

Jerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

button "filter by selection" on a form 3
sort button 2
Quicky 2
remembering strWhere 3
Resetting the form filter filter for a new report 4
Sorting columns in Datasheet view 1
filter question 2
Filter Button 1

Top