Pass shared Variable to Main report thru subreport

Printed From: Crystal Reports Book — Forum Name: Technical Questions

I am having issues with passing subreport data to my main report in a Group Footer.

I can get the data to show but i keep getting a zero dollar pass through in the first group footer. So this makes all my totals off by a group

Example:
GF1
Branch 5 should have 1484.77 but shows 0
Branch 15 should be 4317.00 but shows 1484.77
Branch 22 should be 6011.11 but shows 4317.00

I cannot figure out why the 0 shows up.

I have both groups exactly the same in both main and subreport

subreport code is
whileprintingrecords;
Shared NumberVar INV:= Sum ({@TOTAL}, {@BRANCH})/21

main code is
whileprintingrecords;
shared numbervar INV;
INV;

I have them linked on @branch.

The results you show seem to belong to the previous branch, not to the current one.
That suggests that you are calling the subreport before a branch has reached the expected value. May be? From which section are you calling the subreport?
I found out my issue was because I needed to drop my subreport into a group above my formula. this worked and everything now lines up. But of course this causes issues on my export to excel (data only).
Lots of luck getting everything to line up using a sub-report.  Not impossible, but can be challenging