In the main form, use a query that contains the field you want to group by.
In the subform, use a query that contains the details including the field
used to group the infotmation.
In properties of the subform control on the main form, set the
LinkChildFields and LinkMasterFields properties. In the footer of the
subform, calculate the desired total.
If you want, you can also display that total in the main form:
=subformcontrol.Form!totalfield