Running Total between Main Report and SubReport

I believe I have to use Shared Variables but not sure how...

In Main Report.... in Detaila I have QtyOnHand...

I have a linked SubReport within Detailb...Detailb as 2 values.. 1 is Forecast the other is PO....

I need the QtyOnHand to Add to the Forecast and Subtract the PO... The Result needs then to look at the Next row of Forecast and PO and have a new Result..Continuing all the way however many rows are in the SubReport...at the bottom of the either the SubReport or Main Report I need to be the Net of all Results, Forecasts and PO..

Hopefully this makes sense

I have included a snapshot of what I am looking for in jpeg..
RunningTotal.jpg
Michael KatzAsked:
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.

Mike McCrackenSenior ConsultantCommented:
It can't be done that way.

Assuming the subreports only have 1 row per detail row it is possible.

You need to insert a section below DetailsB.
Move everything except the subreports to detailsC.
Set detailsB to UNDERLAY FOLLOWING SECTIONS

Subreports are the last thing evaluated in the section so the values from the shared variables aren't updated until after the section is rendered.  By moving everything down a section except the subreports, the values will be available in DetailsC and you can calculate the column.

Underlaying will align the subreports so they show appropriately or you can have the subreports show nothing and display the shared values from the main report in details C.

mlmcc
Michael KatzAuthor Commented:
I have created DetailsC....I moved everything to DetailsC that was in DetailsA...DetailsB still shows the sub report...Underlay has been turned on...

But the values haven't changed.. what am i missing?
Mike McCrackenSenior ConsultantCommented:
What was in Details A?

The values in the subreports won't change.  If you want to use the values in the main report you have to do it in Details C.

Can you upload the report?

mlmcc
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Michael KatzAuthor Commented:
Thanks again for putting up with my stupidity...here is the report
POvsForecast.rpt
Mike McCrackenSenior ConsultantCommented:
Your formulas aren't doing any accumulations.

Change the @QtyBal formula to

Shared numberVar QtyOH;
QtyOH := QtyOH + {Forecast.OriginalForecast} - {Forecast.OpenPo}

Open in new window


mlmcc

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
Michael KatzAuthor Commented:
So where is the value for DetailsC??? I thought we needed to add a section.. Not complaining because this works.. just curious
Mike McCrackenSenior ConsultantCommented:
I didn't realize the on hand column was being done in the subreport.  I thought that was in the main report in which case you needed the third details section.

mlmcc
Michael KatzAuthor Commented:
sorry late awarding..but works well
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.