Data from sub-report to main report

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:
//@SubFormula
//Stores the grand total of the Sum {@MtypeTotalCost} field
//in a currency variable called 'myTotal'
WhilePrintingRecords;
Shared NumberVar myTotal := Sum ({ContainerInv.Qty}, {ContainerInv.Product})

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

                   
jpdnorthernAsked:
Who is Participating?
 
PCIRichardCommented:
You probably need a formula in the report header section of the subreport that sets myTotal to Zero

e.g.
Shared NumberVar myTotal := 0

this should reset the value each time the subreport is reached
0
 
jpdnorthernAuthor Commented:
Here is a snapshot from the report.

subreport.jpg
0
 
jpdnorthernAuthor Commented:
Here is the layout design of the report.

subreport2.jpg
0
 
jpdnorthernAuthor Commented:
PCIRichard, Brilliant! Thanks a ton. This has been frustrating me for some time.

Jason
0
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.