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

Filter By Selection

Status
Not open for further replies.

herd

Technical User
Jun 23, 2003
46
US
Is there a code that can filter by selection on a form instead of using the button located on the menu bar?

For example if I selected a field on my form then click a command button I would like it to filter on that selection.

Thanks Gary
 
There is a right-click menu that has what you want, unless it's in a .mdb that has those menus disabled.
--Jim
 
Thanks Jim, I thought there might be some code that can do this.
 
herd,
Well there is code that will do this, but once you've clicked in the field and then go to a button that might run the code, it's fewer steps to just use the built-in right-click functionality already there.

But if you wanted, you'd use Screen.Activecontrol to get the field where the user has the mouse, then get that value, then either call .Filter or reset the form's recordsource with a new sql implementing that selected field's value.

What you could do is use this and instead of using a command-button, just put it in the dbl-click event of the controls. You don't need to code it into each control--just make one function (not Sub), say call it "FilterMe", then do a multiple-select on all controls where you want this functionality, and put in that dbl-click event:
=FilterMe()
...using the "=" and parens. Then the function knows which field via screen.ActiveControl, and the whole filtering is done without right-clicking or a separate button.
--Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top