Grand Total of a calculation from a subreport

I have a report that has Orders and Lines. It has a sub report that has dollars that are tied to the order but not to a line.

I total all the lines up and get a subtotal and then add the Misc charges from the subreport using a shared number variable. Now I would like to add these up to get a total for all the orders for a customer. When I try to sum it tell me I can't summarize this field (the shared variable).

I also can't find the field to do a running total on it.
Here is the code where I share the variable

//Returns the value that was stored
//in the shared Number variable called
//mySubSellTotal in the subreport

Shared NumberVar mySubSellTotal;

//Returns the sum of the misc sell from
//{OP_MISCCHAR.Sell} field
//in a numbervar called 'mySubSellTotal'

Shared NumberVar mySubSelltotal := ToNumber(Sum({OP_MISCCHAR.Sell}))

Any help would be appreciated.

James Stonewarehouse managerAsked:
Who is Participating?
You can't summarize a formula that is evaluated during the WhilePrintingRecords step.  The easiest approach would be to simply add a variable for your customer total.

In @SubSellTotal change the formula to read like this:
Shared NumberVar mySubSelltotal;
Shared NumberVar myCustomerTotal;
mySubSelltotal := ToNumber(Sum({OP_MISCCHAR.Sell}));
myCustomerTotal := myCustomerTotal + mySubSelltotal;

You probably understand from there - add a formula in the Customer group header to reset myCustomerTotal := 0 between customers and in the Customer footer show the result normally.  I can explain further if you need any more details.
James Stonewarehouse managerAuthor Commented:
I got it! Thanks for the tip!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.