Dave Roger
asked on
Passing shared variable from subreport back to main
I have a main report running several sub reports. I would like the value of a sum field (actually a sum of a formula field) calculated in the sub report to be passed back to the main for use in another formula in the main.
In main I have a formula field called subtotal_percap
WhilePrintingRecords;
Shared NumberVar subtotal_percap;
In the sub I have the identically named formula field,
WhilePrintingRecords;
Shared NumberVar subtotal_percap;
subtotal_percap := 99.99;
I have tried a few things, including this last line - 99.99, just to see if the 99.99 can get passed back to main, and it doesn't. I'd actually prefer to have the sum field passed back to main. The sum field I'd like to use is
Sum ({@sum_by_status})
Based on what I saw in other postings here on EE, it looks like I'm doing this right, but @subtotal_percap on the main doesn't show 99.99, it just shows 0.00.
What am I doing wrong? And, what would be the correct syntax to capture the
Sum ({@sum_by_status}) in the shared variable for passing?
thanks
dave
In main I have a formula field called subtotal_percap
WhilePrintingRecords;
Shared NumberVar subtotal_percap;
In the sub I have the identically named formula field,
WhilePrintingRecords;
Shared NumberVar subtotal_percap;
subtotal_percap := 99.99;
I have tried a few things, including this last line - 99.99, just to see if the 99.99 can get passed back to main, and it doesn't. I'd actually prefer to have the sum field passed back to main. The sum field I'd like to use is
Sum ({@sum_by_status})
Based on what I saw in other postings here on EE, it looks like I'm doing this right, but @subtotal_percap on the main doesn't show 99.99, it just shows 0.00.
What am I doing wrong? And, what would be the correct syntax to capture the
Sum ({@sum_by_status}) in the shared variable for passing?
thanks
dave
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That is correct if you want it displayed in the detail section
mlmcc
mlmcc
ASKER
Hi,
almost there. I can see the 99.99 in a subsequent detail section.
When I use this in my subreport
WhilePrintingRecords;
Shared NumberVar subtotal_percap;
subtotal_percap := Sum ({@sum_by_status});
crystal complains and says "a number is required here. "
almost there. I can see the 99.99 in a subsequent detail section.
When I use this in my subreport
WhilePrintingRecords;
Shared NumberVar subtotal_percap;
subtotal_percap := Sum ({@sum_by_status});
crystal complains and says "a number is required here. "
What is the formula @sum_by_status - by its name it should be a number but it could be anything
mlmcc
mlmcc
ASKER
It is a report footer sum of a currency field.
Crystal will not do any automatic type conversion. I know to use a Currency value looks like a number but it is a different data type
Try this formula
Note the change in type to CurrencyVar
mlmcc
Try this formula
WhilePrintingRecords;
Shared CurrencyVar subtotal_percap;
subtotal_percap := Sum ({@sum_by_status});
Note the change in type to CurrencyVar
mlmcc
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks mlmcc and James. you both hit it.
What I did was in the sub report I added the ToNumber function as James suggested. So it became a number when it was passed back "up" to the main report.
(p.s.: mlmcc, I see your byline everywhere here in EE when to comes to Crystal. Very cool. )
What I did was in the sub report I added the ToNumber function as James suggested. So it became a number when it was passed back "up" to the main report.
(p.s.: mlmcc, I see your byline everywhere here in EE when to comes to Crystal. Very cool. )
ASKER
Shared effort, shared solution. thanks to you both.
ASKER
In the report header, then, I would have a formula field called "@dummy" or something equivalent. Then in the main, in a section following the sub, I'd reference another formula field, maybe named "@the_real_thing". Both formula fields can reference the same shared variable?
additonally, to elaborate a bit:
The report has several detail sections (detail a, detail b, etc). This sub report is in detail b.
You're suggesting that I put @the_real_thing perhaps in detail c?