Crystal XI sub-report shared currencyvar not returning value to main report

Main report contains the following @Material Costs formula:
IF ISNULL(Sum ({@Misc Costs}))
THEN {@PO Value}
ELSE IF ISNULL ({@PO Value})
THEN Sum ({@Misc Costs})
ELSE Sum ({@Misc Costs})+{@PO Value}

The formula @PO Value is simply...
shared currencyvar povalue

The Job Matl Sub-report contains the following formula:
@Value
{POReleases.Qty}*{PODet.UnitCost}

@SumPO
shared currencyvar povalue;
Sum ({@Value})

My main report formula @PO Value is supposed to pass the shared currencyvar povalue to the @Material Cost formula; however, I'm only getting the @Misc Cost... missing the Sum ({@Value}) from the Job Matl Sub-report.

Not certain what I'm missing?
Job-Cost-Actual-vs-Estimate.rpt
LVL 9
Lee IngallsDirector of IT/TS, Quality and FinanceAsked:
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:
The formula PO Value should never be null since the declaration of the variable initializes it to 0.

I would add a formula to the report header to declare povalue before the subreport is run.  This is more a style than a necessity.  The subreport then knows where the povalue variable is in the main report.

SInce the job cost subreport is in the report header it only runs 1 time not for each work center.  Is that the right place for it?

If you are trying to use the value from the other subreport (Job Matl) that is in the report footer then you need to move that subreport so it is run before the value is used in the subreport.

Crystal creates the report top down 1 section at a time.  Subreports are the last thing evaluated in a particular section.

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
Lee IngallsDirector of IT/TS, Quality and FinanceAuthor Commented:
I placed a formula @poval in RHa, which declares shared currencyvar povalue.
I'm not concerned (for now) with the work centers, etc in (GH1). So long as their columns SUM to RFa to be used in @Total Labor.

RFa, contains:
     @Total Labor --> Sum ({@Labor})+Sum ({@Burden})
     @Material Costs simplified to --> Sum ({@Misc Costs})+{@PO Value}
     @Total Costs --> ({@Total Labor})+({@Materials Costs})

Where @Material Costs, @PO Value --> shared currencyvar povalue

I understand what you're saying about Crystal processing top down... and the Job Matl sub-report needing to run before it's value is needed in RFa's totals formula; so I saved the job material sub-report as Job Matl Subrpt2 and placed it in RFd and placed the original Job Matl Subrpt in RHb.

Unforntuately with the exact same results... @Material Costs is only picking up @MiscCosts values; still no value from shared currencyvar povalue.

My heads spinning.
Doc6.pdf
Mike McCrackenSenior ConsultantCommented:
Can you upload the report with some saved data?

mlmcc
James0628Commented:
I didn't actually look at your report, but the SumPO formula in your first post is not actually setting the variable.

 You have:

shared currencyvar povalue;
Sum ({@Value})


 I am assuming that you want povalue to contain the total of the Value formula.

 To get the total from a single subreport, that should be:

shared currencyvar povalue;
povalue := Sum ({@Value})


 If the subreport is run more than once and you want to accumulate the total from all of the subreports in that variable, it would be:

shared currencyvar povalue;
povalue := povalue + Sum ({@Value})


 James
Lee IngallsDirector of IT/TS, Quality and FinanceAuthor Commented:
Once again EE proves it's value! Thank you mlmcc for the proper usage/placement of the shared currencyvar; and also to James0628 for pointing out I wasnt declaring the variable correctly. Both experts contributed to a successful solution.
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.