Grand Total of a calculation from a subreport

Posted on 2006-04-11
Last Modified: 2008-01-09
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.

Question by:cubbyboy57
    LVL 42

    Accepted Solution

    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.

    Author Comment

    I got it! Thanks for the tip!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
    There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now