Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to do a Grand Total in a Main Report off a subreport field

Status
Not open for further replies.

Garyjr123

MIS
Sep 14, 2010
139
US
I need to find out how to do a grand total in my main report from a summary I put into my subreport. Basically, I have patient amounts added together so I get a total patient summary for a billing run in the report footer subreport. Now, I would like to have a grand total of the whole billing run show up in my main report (the main report footer).

Thanks,

Gary
 
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
 
LB,

As usual you are a huge help. This worked great thanks but now I have another thing I would like help with.

I want to return the null values in my subreport as $0.00. Basically, everything is returned but the null value for one patient charge item. How do I go about doing this?

Gary
 
Do you mean within the sub in the detail section? You could just go into file->report options->convert nulls to default values. Or, you could instead write formulas like this:

if isnull({table.charge}) then
0 else
{table.charge}

If you are referring to the shared variable being null, that could only happen in the first subreport since I didn't have you add a reset to the report header. So try adding the reset formula ALSO to the report header, as well as the GF.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top