download/file.php?id=14591
The main form takes filter criteria which substitute the subform's parameters. In order to make this work without macro code, the main form's criteria values need to be stored somewhere. The filter criteria are stored in a distinct record of a separate table:
Code: Select all
select * from "Filter" WHERE FID=1
.
The 4 filter criteria from date, until date, category ID, and person ID are evaluated like this:
Code: Select all
SELECT "PID", "CID", "D", "V", "ID"
FROM "Data"
WHERE ("PID"=:paramP OR :paramP IS NULL)
AND("CID"=:paramC OR :paramC IS NULL)
AND("D">=:paramD1 OR :paramD1 IS NULL)
AND("D"<=:paramD2 OR :paramD2 IS NULL)
Any missing parameter returns True for the respective condition, ignoring the missing parameter.
The filtered record from the "Data" table is editable because it is not joined with any other table.
There is a second subform which calculates sum, count, average, min, max based on the same criteria stored in "Filter" WHERE FID=1. This subform joins the data table directly with the filter record. The calculation result is read-only anyway. It is possible to do the same trick with a parameter query like the one in the filtered table grid. Just replace the selected field names with SUM(...), COUNT(...) etc.
The reports in that database document use the same filter criteria.