Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Shared variable from Subreport Post Reply Post New Topic
Author Message
cbaldwin
Groupie
Groupie


Joined: 09 Apr 2014
Online Status: Offline
Posts: 81
Quote cbaldwin Replybullet Topic: Shared variable from Subreport
     Posted: 09 Jul 2014 at 4:36am
I have created a shared variable in a formula on my sub-report as follows.

//stores the maxsumdivision VARIABLE for sharing with main report. The variable diplays the correct data on the sub report.

Whileprintingrecords;
shared numbervar maxsumdivision:= Maximum ({@division status})

I have attempted (without success) to share this variable in a formula and see it on the main report so I can use it there.

// maxsumdivision VARIABLE from component shipment sub report

whileprintingrecords;
shared numbervar maxsumdivision;
maxsumdivision := maxsumdivision;

I have never attempted shared variables before so used some formatting that I have seen online without success. I have no idea if the whileprintingrecords statement needs to be there or not. I also am not sure of the proper syntax. Any help is greatly appreciated.

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Jul 2014 at 5:18am

the main report formula placement has to be in a section below where the subreport is placed and run. E.g. subreport in groupheader1 and mainrpeort varibale in groupheader2

the subreport cannot be suppressed or it does not run and therefore will return no value
IP IP Logged
cbaldwin
Groupie
Groupie


Joined: 09 Apr 2014
Online Status: Offline
Posts: 81
Quote cbaldwin Replybullet Posted: 09 Jul 2014 at 6:09am
my sub report is in group header 1
and my main report variable is in group footer 1

would this be why my variable = 0 as opposed to 1 as it does in the sub report

the subreport is "on demand"
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Jul 2014 at 7:07am
i do not beleive it can be on demand.
it has to run at the same time as the main report and it cannot be suppressed. There is a trick to suppress it if needed, but out of the box it cannot be suppressed.
IP IP Logged
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