Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter by form command button

Status
Not open for further replies.

jimiH

Programmer
May 14, 2001
4
0
0
GB
Is there a way to put a button on a form for Apply/Remove Filter? I want users (who are not at all Access-savvy) to be able to Filter By Form without having to go up to the toolbar. I figured out a way to make a command button for Filter By Form, but the problem is that once you press this button and enter criteria, you still have to go up to the toolbar and click on Apply Filter. I tried, with my very limited vba skills, to create a command button for Apply Filter on the form itself, but when you press the Filter By Form button I created, which you have to do first so you can enter search criteria, my other command buttons get grayed out. Will my database users just have to learn how to go up to the toolbar to Apply or Remove their filters?

Thanks

Geoff"

 
What the Apply Filter toolbar button does is set the FilterOn and OrderByOn properties of your form. You can do this yourself in VBA code:
Me.FilterOn = True (to turn Apply Filter on)
Me.FilterOn = False (to turn it off)
If your filter specifies sorting criteria as well, you should set the OrderByOn property as well.

The bigger problem for you seems to be that the command button is disabled on the form. Access automatically disables all controls that aren't bound to a field, when it builds the filter version of a form. However, I believe you can override this by reenabling the control in the Filter event. If you do this, your users can simply click your Apply Filter button after entering their search criteria. Rick Sprague
 
Hi guys, am having exactly the same problem! I actually created the command buttons by a DoMenu function in code which literally just emulates functions ad verbatim as they appear on the menu bar. This is really useful as you can create buttons such as 'activate filter by form', 'apply filter', 'remove filter' with much ease by simply referring to the menu bar in the command button code.

However, would really like to know how EXACTLY to overide my new command button 'Apply Filter' getting grayed out when I activate 'filter by form'!!!!

Does anyone know how to do this?

Dom from UK
 
Geoff, Dom,

Before diving in, has anyone tried Rick's suggestion of putting
Code:
cmdApplyFilter.Enabled = True
in the Form's OnFilter or the OnClick Event of the button that activates the filter by form?


John

Use what you have,
Learn what you can,
Create what you need.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top