Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Global Summation Post Reply Post New Topic
Author Message
redboan
Newbie
Newbie


Joined: 06 Jun 2007
Location: United States
Online Status: Offline
Posts: 8
Quote redboan Replybullet Topic: Global Summation
    Posted: 22 Jun 2007 at 11:44am
Hello,

I'm having one small issue.  I have 13 subreports, and in these subreports, I have a formula that adds up certain data fields.  However, I need a formula in which it adds up all these fields globally but have been unsuccessful to do so.

If anybody could shed some light on this, that would be fantastic.

Thanks,
Adrian
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 22 Jun 2007 at 2:49pm

You could use a set of shared variables - one for each subreport.  Declare them and set their initial values to 0 in the main report.  Something like this:

BeforeReadingRecords;
Shared NumberVar sub1 := 0;
Shared NumberVar sub2 := 0;
...
Shared NumberVar sub13 := 0;
 
In each subreport, you would use the corresponding shared variable that's declared in the main report.  So in Subreport 1, you would have something like this:
 
Shared NumberVar sub1;
sub1 := sum({table.field});
 
Repeat for each variable and subreport.
 
In your main report, you would then have another formula that would add all of the values of these shared variables together:
 
Shared NumberVar sub1;
Shared NumberVar sub2;
...
Shared NumberVar sub13;
 
sub1 + sub2 + ... + sub13
 
Put this final formula on the report to display your total.
 
Note that you MUST declare the variables in EVERY formula where they're used.  It's the only way that Crystal knows how to use them.
 
-Dell
 
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
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



This page was generated in 0.016 seconds.