Hello,
This is power filtering. Use of a one record table which contains the variable(s) to be used in your query. There are numerous examples throughout this forum. Most are for filtering records for display on a form. In your case this same technique can be used but you really don’t even need a form. Just change the data in the Filter table record and see results in your query.
In my answer on this post → Need to create a form to enter a record ID to delete there is a link to ‘Filter/Searching with Forms’ which goes into more details about this. This answer also has an example. This example is the basis of what you want.
Another sample is in my answer here → Need to Filter a table with two fields for key words
Edit:
@dougmn You are nearly on the right track. The filter table, which only uses one record, needs a key field (1st field - Integer - NO auto increment) and a field for each of the variables you may have. It doesn’t need to be a duplication of the table record you are querying. It doesn’t even need to have the same field names. It is simple a “holding” area to use in your SQL.
Have attached a sample – TableFilter.odb
Open the table TableFilter
. Change values in Color
or Wheels
fields of record (be sure to save record) then run the query SampleFilterSelect
. Change TableFilter
value(s) or delete a value & re-run query. Results will change as data in filter table is changed.
Note: You can, as originally asked, create a form which would fill in parameters & even execute the query but it would require macro code specifically to your design. In this case the TableFilter would not even be used.