Avatar of azizi jaafar
azizi jaafar
Flag for Malaysia asked on

Crystal Report XI Issue : Shared Value from Subreport not shown in the right link

I have created Main Report - Outlet Performance to read the cost and Subreport to read the sales
This is the formula in main report :
WhilePrintingRecords;

Shared NumberVar ShareSales;
""
And this is the formula from subreport:
Name of Formula: ShareSales

WhilePrintingRecords;

Shared NumberVar ShareSales;

ShareSales := Sum ({_DemandDtl.BatlD}, {_OUTLET.CPU});

""
I tried to run subreport, it working fine with the sharesales figure, but the moment I add to the main report, the share figure jump to next record (next outlet). It do not follow the link set in the subreport link
Outlet-Performance.jpg
outlet-performance-report.pdf
Crystal Reports

Avatar of undefined
Last Comment
James0628

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
James0628

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
azizi jaafar

ASKER
Please elaborate  further .  I am using the same section in the main report @section Ga and hide the detail section. I am using the same section for sub report.
In subreport , the result only shown in Ga Section.
James0628

You accepted my post as the solution.  Does that mean that you figured it out?

 If not, the idea is that if, for example, you have the subreport in GH1, you would need a second GH1 section.  The subreport would be in GH1a and the formula would be in GH1b.  Or, another approach would be to put the subreport in the group header, and the formula in the group footer.

 If you want to display the subreport data and the main report formula side-by-side, there are ways that you could do that.  The best approach may depend on how much data you're displaying in the subreport.

 James
azizi jaafar

ASKER
Thanks, Got it
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
James0628

OK.  Just wanted to make sure.

 James
azizi jaafar

ASKER
I have another issue to obtain summary total in the main report for the following fields:
1 Demand and Sales (Extracted from sub report)
2. Gp is calculated field (Sales less COST)
Trying to use running total , but is not available. appreciate your help to write in the formula with detail example.

Thanks.
RunningTotal-Formula.jpg
James0628

You need to use a variable if you want a total for a variable from a subreport.  Using the ShareSales variable as an example, say you had this formula to output the variable in the main report:

WhilePrintingRecords;
Shared NumberVar ShareSales

 You could change that formula to:

WhilePrintingRecords;
Shared NumberVar ShareSales;
Shared NumberVar TotalSales;
TotalSales := TotalSales + ShareSales;
ShareSales

 Then you could use a formula like the following in the report footer to output the grand total:

WhilePrintingRecords;
Shared NumberVar TotalSales


 James
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
azizi jaafar

ASKER
What is the variable/formula for TotalSales? I got 0.00 result in sub report.
James0628

TotalSales is a new variable I was creating in the main report.  The idea is that each time you run the subreport, you have a formula in the main report add the value from the subreport to the new variable.  I wasn't really intending for you to use TotalSales in the subreport.  I was just trying to produce a grand total for the end of the main report.

 That's not to say that you can't use TotalSales in the subreport.  That just wasn't what I had in mind.  What were you trying to do with TotalSales?  What's in the formulas that use it, and where are they located?

 James