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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.