So the sub is in a patient group in the main report and linked on the patient field? In the subreport footer, create a formula like this:
whileprintingrecords;
shared numbervar amt := sum({table.bill});
Let's say the sub is in Group Header #1 of the main report.
Insert a GH1b section and add this formula to it and then suppress the formula and the GH1b section:
whileprintingrecords;
shared numbervar amt;
numbervar sumamt := sumamt + amt;
Then in the report footer, add a formula like this to display the results:
whileprintingrecords;
numbervar sumamt;
If a subreport can have no results, you need a reset formula in GF#1:
whileprintingrecords;
shared numbervar amt := 0;
If your billing amount is a currency, not a number, use currencyvar instead of numbervar in all formulas.
-LB