Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Help w/Shared Variable from SubReport to Main Post Reply Post New Topic
Author Message
JGARDNER-AIT
Newbie
Newbie
Avatar

Joined: 27 Jan 2010
Location: United States
Online Status: Offline
Posts: 11
Quote JGARDNER-AIT Replybullet Topic: Help w/Shared Variable from SubReport to Main
    Posted: 11 Jul 2011 at 5:58am
Hello - I need help passing values from a subreport "detail" to a main report detail. What I need is the value from the subreport to be in its own column on the main report and also use the value to decrease a onhand inventory value in a formula field on the main report. I have tested with some of the examples I found on net, but it only works for one part number. When I have a list of onhand inventory of like 62,000 records, the value from the subreport doesnt change and applies the same value to all part numbers. So I think I'm close.... but need expoert help.
 
Thanks - Josh
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 11 Jul 2011 at 10:14am

Shared variables are used to pass values from sub report to the main report.

(if you want  to summarize totals from a sub report with totals from the main report, you would use the following formulas to pass the value from the sub report to main report.

 

SUB REPORT                          

 whileprintingrecords;
SHARED Numbervar  X := x + {field};

 

MAIN                                      

whileprintingrecords;
SHARED Numbervar  X;
X

 

Shared variables can not be suppressed.

Make the font white and the field very small.

They must be placed below the subreport to retrieve the value.

if you want the value per part number you will need to create a group by part id.
sum your values and place that in the the sub report
the shared variable in the sub should be in the group footer.
sharona
IP IP Logged
JGARDNER-AIT
Newbie
Newbie
Avatar

Joined: 27 Jan 2010
Location: United States
Online Status: Offline
Posts: 11
Quote JGARDNER-AIT Replybullet Posted: 11 Jul 2011 at 10:46am

Hello Sharona - I followed your example "per part number" and I still get the same results.  Anything else I can try?

Thanks - Josh
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 12 Jul 2011 at 1:52am
start with the sub report with no links to the main report.
create your part number group
get your data and get your summaries.
are you using the summary wizard or manual runnning totals?
 
then create your shared variable in the sub.
you may need to create a reset formula for the shared varaible
 
whileprintingrecords;
shared numbervar x := 0;
x- is your variable name
 
then create you group by part number in the main report
place your sub report in the details of the group
then join your sub to the main by part number
you should see the values in the sub for the part number when you run the main report
then create your shared variable in the main report
make sure it is below the sub in the group footer of the main
DO NOT SURPRESS THE SHARED VARIABLE IN THE or you wont get anything.
 
sharona
IP IP Logged
JGARDNER-AIT
Newbie
Newbie
Avatar

Joined: 27 Jan 2010
Location: United States
Online Status: Offline
Posts: 11
Quote JGARDNER-AIT Replybullet Posted: 12 Jul 2011 at 8:38am
Hi Sharon - Thank you for your time.
 
I'm not displaying a value for the shared formula on my main report page.
Heres what I have for my subreport shared variable.
 
SubReport Formula: (stored in gf)
WhilePrintingRecords;
shared NUMBERVAR zcust := sum({Part Stock.QTYOH_06});
 
Main Report Formula: (stored in gf)
whileprintingrecords;
SHARED Numbervar  zcust;
zcust
 
 
If you would like, I can send you a copy of this report if it makes it easier.
My email address is jgardner@aitint.com
 
Thanks for your help... Josh
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 12 Jul 2011 at 9:20am
did you get your value in the sub report first?
sharona
IP IP Logged
JGARDNER-AIT
Newbie
Newbie
Avatar

Joined: 27 Jan 2010
Location: United States
Online Status: Offline
Posts: 11
Quote JGARDNER-AIT Replybullet Posted: 12 Jul 2011 at 9:39am
Yes
IP IP Logged
rpatel
Newbie
Newbie


Joined: 13 Oct 2011
Online Status: Offline
Posts: 1
Quote rpatel Replybullet Posted: 13 Oct 2011 at 6:22am
I am having the same issue here with resetting the shared variable to display total by group from the subreport it is only displaying the last group total. Any suggestions?

I have the shared variable in the GF#1 section in both the main and sub report and groupings are the same in both as well.
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.