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
azizi jaafarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

James0628Commented:
You have to put the main report formula in a section after the one that contains the subreport.  Subreports seem to be the last thing processed in a section, so when the formula and subreport are in the same section, the formula is evaluated first, giving you the result from the previous subreport, and then the subreport is run again.

 James
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
azizi jaafarAuthor Commented:
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.
0
James0628Commented:
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
1
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

azizi jaafarAuthor Commented:
Thanks, Got it
0
James0628Commented:
OK.  Just wanted to make sure.

 James
0
azizi jaafarAuthor Commented:
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
0
James0628Commented:
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
0
azizi jaafarAuthor Commented:
What is the variable/formula for TotalSales? I got 0.00 result in sub report.
0
James0628Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.