Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Subreport Totals and Mainreport Totals Post Reply Post New Topic
Author Message
rburke72
Newbie
Newbie
Avatar

Joined: 03 Aug 2011
Online Status: Offline
Posts: 13
Quote rburke72 Replybullet Topic: Subreport Totals and Mainreport Totals
    Posted: 06 Nov 2011 at 8:07pm
I created a subreport that included a total by group.  I also have total by group in the main report.  How do I combine the total from the subreport to the main report total?
Racquel Burke
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 07 Nov 2011 at 2:21am
used a shared variable to bring the subreport total to the main report. Then you will just need to add them together.
|< /\ '][' ( )
IP IP Logged
rburke72
Newbie
Newbie
Avatar

Joined: 03 Aug 2011
Online Status: Offline
Posts: 13
Quote rburke72 Replybullet Posted: 07 Nov 2011 at 3:02am
How do I do that?  It is also grouped by date.
Racquel Burke
IP IP Logged
rburke72
Newbie
Newbie
Avatar

Joined: 03 Aug 2011
Online Status: Offline
Posts: 13
Quote rburke72 Replybullet Posted: 07 Nov 2011 at 3:26am
What would the formula be if there is a subreport total and main report total but if there is 0 in the subreport total the main report total is the total by date. 
Racquel Burke
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 07 Nov 2011 at 7:48am
The shared variable needs to be created in both the Subreport and the main report. You will declare the value of the variable in the subreport:

whileprintingrecords;
shared numbervar nTotal:=(the total by group field);


And you will display the value in the main report:

whileprintingrecords;
shared numbervar nTotal;


To get the subreport to run properly for the group, you will need to devise a way to get the subreport to only run for that group date. To achieve this, I believe you will have to create another shared variable that takes the date of the group from the main report and passes it to the subreport. The subreport should then use this date in the Record Selection Formulas. This will limit the subreport to run only for the current group date.

Something to remember. The shared date variable from the main report needs to be calculated before the subreport. So you will probably need to place it in the Group Header.

Also, the Subreport needs to be run in a section before you can use the shared variable that comes from it. For this, you may need to have a Group Footer A and Group Footer B. The subreport would be put in A and the combined total would be put in B.
|< /\ '][' ( )
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.