Data from sub-report to main report

Posted on 2009-04-29
Last Modified: 2012-08-14
I have a Crystal Report in which has 1 sub report. I have the formulas on both the sub-report and the main report to bring in the data from the sub. I believe I have them in the proper order on my report so Crystal evaluates the formula properly. My issue is, the formula returns the proper value from the sub report but then that value is repeated on the main report until a new value is found on the sub while it should just be zero.

Formula on sub:
//Stores the grand total of the Sum {@MtypeTotalCost} field
//in a currency variable called 'myTotal'
Shared NumberVar myTotal := Sum ({ContainerInv.Qty}, {ContainerInv.Product})

Formula on Main:
//Returns the value that was stored in the shared currency variable called
//myTotal in the subreport
Shared NumberVar myTotal

Question by:jpdnorthern

    Author Comment

    Here is a snapshot from the report.


    Author Comment

    Here is the layout design of the report.

    LVL 7

    Accepted Solution

    You probably need a formula in the report header section of the subreport that sets myTotal to Zero

    Shared NumberVar myTotal := 0

    this should reset the value each time the subreport is reached

    Author Comment

    PCIRichard, Brilliant! Thanks a ton. This has been frustrating me for some time.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Suggested Solutions

    I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
    Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    779 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

    11 Experts available now in Live!

    Get 1:1 Help Now