Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Shared Variable rolling over to next record Post Reply Post New Topic
Author Message
flanman
Senior Member
Senior Member
Avatar

Joined: 04 Nov 2009
Online Status: Offline
Posts: 123
Quote flanman Replybullet Topic: Shared Variable rolling over to next record
    Posted: 07 Apr 2010 at 7:12am
I have a report with a subreport. In the subreport I created a shared variable I want to carry over to the main report:
Shared NumberVar SubAvgPerformed;
SubAvgPerformed :={@AvgPerformed};
I included this formula in the sub report and suppressed it.
I my main report I have the following formula to bring in the shared variable:
Shared NumberVar SubAvgPerformed;

I now have a formula using this value to show a variance on the main report:
{#Drive_ProcedureProjection} - {@SubAvgPerformed};
This last formula is placed in a group footer below where the sub report is showing/calculating the values.

All is working fine except when I get to a record where there is no value in the sub report. When this happens I get the value from the previous record for my shared variable. So... my question is how to I clear/reset the shared variable after each record?

Flanman


IP IP Logged
chris
Newbie
Newbie


Joined: 02 Apr 2008
Location: United Kingdom
Online Status: Offline
Posts: 35
Quote chris Replybullet Posted: 07 Apr 2010 at 9:57am

You need to create a formula with the following

shared numbervar SubAvgPerformed:=0
 
This formula needs to be placed in a section above the subreport in a section which would be run for each record i.e. not report header, page header - probably in Group Header 1 at a guess. Therefore everytime the subreport is run the variable should get reset. If a value is found in the subreport it will be displayed. If no value is found a 0 should be shown.
 
Chris
IP IP Logged
flanman
Senior Member
Senior Member
Avatar

Joined: 04 Nov 2009
Online Status: Offline
Posts: 123
Quote flanman Replybullet Posted: 07 Apr 2010 at 10:48am
Worked like a charm. I was trying to do something similar, but I was trying to put the reset formula in a footer below instead of the header above which was not working. Thanks for the help.
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.031 seconds.