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

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

WhilePrintRecords;
Shared NumberVar mySubSellTotal;
mySubSellTotal

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

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

Any help would be appreciated.

Thanks,
james
Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
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:
WhilePrintingRecords;
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.

Experts Exchange Solution brought to you by