cancel
Showing results for 
Search instead for 
Did you mean: 

Passing a variable from subreport to main report

Former Member
0 Kudos

Hello,

Was hoping to get some assistance on this issue I'm facing.  I've got a sub-report that calculates a monthly goal based off the date selection criteria. And I'd like to pass this goal back to the main report.

In my sub-report, I created a new formula named ProcGoalVariable:

WhilePrintingRecords;

Shared Numbervar ProcedureGoal := cdbl({#ProcGoal})

While {#ProcGoal} is a running total I created for the sub-report and now I'd like to pass it back to the main report.

In the main report, I created a new formula named ProcGoalVariable:

Shared NumberVar ProcedureGoal;

ProcedureGoal;

But when I drop this into my report, it is returning a value of 0.  In the screen shot, the Proc. Needed should actually equal the Proc Goal:

Any suggestions on how to pass this correctly?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Thanks for the advice,

I want to rewind a bit to make sure I am explaining myself clearly.  My sub-report is pulling the correct numbers and it is located in GF#3 and contains two values that fall under "Proc Goal" and "Prod Goal". These are being calculated correctly and I would then like to pass them back to the main report for additional calculations done on this.

In the sub-report, a formula was created "ProcGoalVariable":

WhilePrintingRecords;

Shared Numbervar ProcedureGoal := cdbl({#ProcGoal})

In the main report, a formula was created "ProcGoalVariable"

Shared NumberVar ProcedureGoal;

ProcedureGoal:=ProcedureGoal;

Would having the same name inside the formulas being causing the issue? And I've tried inserting a new section below the section where my subreport lives and I still get a value of 0.

Not sure what else to try at this point.

abhilash_kumar
Active Contributor
0 Kudos

Have you tried changing the formula on the Main Report to:

whileprintingrecords;

shared numbervar ProcedureGoal;

-Abhilash

Former Member
0 Kudos

I just tried and it did not resolve the issue.

Thanks,

abhilash_kumar
Active Contributor
0 Kudos

Would you be able to share the report with saved data please?

-Abhilash

Former Member
0 Kudos

Sure, and I appreciate your time and assistance.

https://drive.google.com/file/d/0B8ErGi0v2xIJUVdJNjZvaVRUMXM/edit?usp=sharing

Thanks,

sylvainchevalle
Employee
Employee
0 Kudos

Hi Trey,

OK I see your problem. In your subreport simply insert your @ProcGoalVariable in the FOOTER in an hidded part of the subreport like this:

That should make the final result of your variable available for the main report but then you have to manipulate it always after the Group footer 3a anyway.

Regards,

Sylvain

Former Member
0 Kudos

Thank you kindly, that worked.

Answers (3)

Answers (3)

sylvainchevalle
Employee
Employee
0 Kudos

Hi Trey,

Which value do you see in your variable at the end of the subreport?

If it is not the expected value then you still an issue in the subreport....

If you see the value in the subreport then try to assign the value to your return variable in the main report... as you describe it, it seems that is still empty...

like :

Shared NumberVar ProcedureGoal;

ProcedureGoal:=ProcedureGoal;

Good luck and Kind regards,


Sylvain

Former Member
0 Kudos

Hi,

I think at last running total has 0 values in sub-report,

you can check all the possible values by assigning it to

a shared string variable say X and then read it in your main report.

I faced the same situation before.

Regards,

Raghwendra.

abhilash_kumar
Active Contributor
0 Kudos

Hi Trey,

The Subreport has to be in a section above the formula that refers to the shared variable. Also the section that holds the subreport should not be suppressed for the shared variable to show the right value.

-Abhilash

Former Member
0 Kudos

Hello Abhilash,

I'm not entirely sure what you mean by placing the sub-report in a section above the formula. My sub-report is in GF #3 and I placed the variable in GF#2 but the value being returned is still 0. I've tried placing the variable in various section including GH #3, GF #1 but nothing.

I've also inserted a section below GF #3 to create a GF #3A and GF #3B with the sub-report in GF #3A and the variable in GF #B.

Suggestions?

Thanks,

abhilash_kumar
Active Contributor
0 Kudos

Unless there is another formula 'resetting' the variable back to zero somewhere between the sections, I don't see why this should happen.

Is GF3 suppressed? Is it set to 'hide (show on drilldown)?

-Abhilash