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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Access' Filter Buttons on my Form

Status
Not open for further replies.

OverDrive

IS-IT--Management
Dec 11, 2000
268
US
I would like to know how to create the filter buttons used in the default access menu to place on my current created form? This would allow for a much easier use of filtering since most people using the database are not familiar with the current filter process.

Any Help?
OverDrive
 
Throw a command button on your form or let a wizard do it for you (if it does, scrap all but the error handling code) then add within the on click event:
DoCmd.ApplyFilter , "[FieldtoFilterIn]= 'whatever'"
You'll need a second button to remove the filter, as above:
DoCmd.RunCommand acCmdRemoveFilterSort
Highlight ApplyFilter when you're in VB and hit F1. There are some decent examples.

Gord
ghubbell@total.net
 
I went to the wizard, but it does not give me the same filter functions as the ones on the current menu for access. the only available functions from the wizard are "Apply form Filter" and "Edit form filter". I would like the "Filter by Section" and "Filter by Form" and "undo Filter" commands (if possible)

Any Ideas?
OD~
 
As above, just let the wizards do the rough work for you..saves typing. Remove the commands it puts between the error handling and replace with code as above. Did you research ApplyFilter yet? Gord
ghubbell@total.net
 
Man, this must be easier than I am trying to make it. you'll have to excuse me, I am kinda new to the VBA side of things. What portion do you mean when you say "between the error handling"? Also, the code you specified seems to only filter a portion of the form that I choose, how does it work like the normal Access buttons on the toolbar (example) once you hit the button it brings up all blank fields and allows you to choose what you want to filter?

I know I am probably sounding like an idiot to you and you have also explained it to me in more plain English that you can, but I need a little more step by step help along.

Sorry, thank you a ton for helping
OD~
 
No sweat: Your typical Access wizard labels the "Private Sub" like "Private Sub NameOfTheControl_NameOfTheEvent()
Then it tosses in the first part of error handling:
On Error GoTo Err_NameOfTheControl_NameOfTheEvent
(This means if there is an error with the code go to...)

Here is where you find the real "Code" that actually does what you're asking. It probably looks like:
DoCmd.DoMenuItem acFormBar....
So you should remove it & replace.
I'm not finished!

Exit_NameOfTheControl_NameOfTheEvent:
Exit Sub Is wizard generated and if you understand that the computer reads from top to bottom means your procedure is over as we are told to "Exit"

Err_NameOfTheControl_NameOfTheEvent:
MsgBox Err.Description
Resume Exit_NameOfTheControl_NameOfTheEvent
This is the error handler that will give you the error message then resume back up to the exit...which in turn, exits the sub!

Gord
ghubbell@total.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top