Simply restrict a query on the Include column, e.g.
SELECT
AVG(Qty) AS AvgQuantity,
MIN(Qty) AS MinQuantity,
MAX(Qty) AS MinQuantity,
AVG(Rate) AS AvgRate,
MIN(Rate) AS MinRate,
MAX(Rate) AS MaxRate
FROM YourTable
WHERE Include = TRUE;
You could create a form bound to this query and then open it from a button
in the footer of a form bound to the table once the user has checked the
Include field for the records in question. Be sure you first save the
current record in the first form though, so the code to open the second form
would be along these lines:
RunCommand acCmdSaveRecord
DoCmd.OpenForm "frmAggregations"
If you use scubadiver's idea of a subform based on the aggregate query
(which is a good one) then you don't need to open a second form; you can
simply requery the subform in the AfterUpdate event of the Include check box
on the main form:
RunCommand acCmdSaveRecord
Me.sfrAggregations.Requery
The subform would then update dynamically whenever Include is checked or
unchecked on the main form. Note that sfrAggregations is the name of the
subform control in the main form, i.e. the control which houses the subform,
not the name of its underlying form object; unless both have the same name of
course.
Ken Sheridan
Stafford, England