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
James Stonewarehouse managerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

frodomanCommented:
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

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
James Stonewarehouse managerAuthor Commented:
I got it! Thanks for the tip!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.