I want the filter to be applied by the code
If I interpret that correctly, you'd never be able to use one parameterized query for several forms because the form names would be different. One way could be to have no query criteria but then apply a filter to it. Not highly efficient if you end up first loading hundreds of thousands of records into a query only to filter it after that. Most other efficient methods would require code, I think. One might be to have the same unfiltered query but grab the sql from it, add the WHERE clause based on your particular form and control(s) and run that from code. Lots of ways I imagine, most of which I'd say are better than having 24 versions of the same query for basically the same thing as so many seem to be doing.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.