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

Who is Participating?
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
jpdnorthernAuthor Commented:
Here is a snapshot from the report.

jpdnorthernAuthor Commented:
Here is the layout design of the report.

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

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.