U did NOT say, UR environment/version details
Basically U require a trigger event, I will assume it is GUI
On a button trigger, on choose / on click event, this is where U require a procedure.
So the button has the required code to specify a where requirement,
This then opens the query with...