Print Page | Close Window

Shared Variables

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Tips and Tricks
Forum Discription: Have you learned some great tricks to share with the group? Post them here!
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=2617
Printed Date: 19 May 2024 at 5:55am


Topic: Shared Variables
Posted By: BlakeJ
Subject: Shared Variables
Date Posted: 14 Mar 2008 at 8:40am
I have a main report using a subreport.  In the subreport I have a shared variable that counts the number of times an item appears.  I am able to bring the shared variable over to the main report so that each subreport shows its own total, for example 0, 1, 3, 1, etc.  The problem I'm having is I can't seem to find a way to have the main report sum these values for an overall total at the bottom of the main report. I get an error that says I cannot sum the shared variable.  I haven't run across a solution to this in any of the forums yet.

-------------
Blake



Replies:
Posted By: SpruceGoose
Date Posted: 24 Apr 2008 at 7:07pm
I'm not sure I understand exactly what you're after, but I'll take my best stab at it.  When you want to get a summary of shared variables from a subreport that have been output to a group footer in the main report, you can use the following method.  Create the following 2 formula fields and enter the formulas below.

Total Shared Variables

WhilePrintingRecords;
Shared numberVar tsv;
tsv := tsv + {your shared variable}


Grand Total Shared Variables

WhilePrintingRecords;
Shared numberVar tsv;
tsv


You'll want to change the variable declarations depending on your data type.  Insert a section below Group footer #1a, and put the Total Shared Variables formula field in that new section, you can suppress this, as it's just a running total.  Then place the Grand Total Shared Variables formula field in the report footer.  Preview the report and you'll have a grand total of your shared variables. 

I hope that helps. 





Print Page | Close Window