Joined: 06 Oct 2009
Location: United States
Online Status: Offline
Posts: 4
Topic: Multiple Subreports with Multiple Shared Variables Posted: 06 Oct 2009 at 7:32am
I am working with a Main report that consists of 30+ Subreports, all of which are exactly the same except for the Program which they are under. Each subreport has 10 Sums that need to be shared with the Main report so that it will show different groups of Grand Totals for each of the sums.
My question: Is there a way around having to create 300+ different formulas with shared variables in the main report to refrence each of the variables in the subreport just to get a sum?
Is there no way to refrence subreport1.sumOfColumn1 + subreport2.sumOfColumn1 + ... + subreportX.sumOfColumn1 ?
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Posted: 06 Oct 2009 at 9:25am
You can reference all the subreport variables from the main report by declaring them in a single formula:
Global NumberVar SR1_C1, SR1_C2, SR2_C1, SR2_C2;
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Posted: 06 Oct 2009 at 2:03pm
are the subreports being run in their own section and BEFORE the section that the main report does the calculation? If they aren't in their own section, then you can't guarantee the order that they are calculated internally and can return zeros without you realizing it.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
Joined: 06 Oct 2009
Location: United States
Online Status: Offline
Posts: 4
Posted: 07 Oct 2009 at 12:13pm
Well I figured out why it wasn't working. The shared variables weren't handling null values correctly for some of the columns so since the second column was actually null, nothing that was calculated after that worked.
Every variable now has something like:
shared numbervar r1_c1:= ( If ISNULL(Sum (@r1_c1)) THEN 0 ELSE Sum (@r1_c1)));
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum