Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying a shared stringvar from subreport to the main report 1

Status
Not open for further replies.

SharenJ

Technical User
Nov 18, 2010
9
CA
I have setup a shared stringvar formula in a subreport:
WhilePrintingRecords;
shared stringVar Pension;
if isnull ({@Pension}) then "N" else
Pension := {@Pension}

The @Pension formula above is:
if {BENEFITS.ST_DATE}< date (2012,04,01) and
{BENEFITS.START_CD} = "Y" then "Y" else "N"

When the subreport is inserted into the main report it is linked by the employee number and then placed in the details line. It displays the correct information “Y” if the employee is in the pension, “N” if the employee is not or if there is no value/Null.

When I do the following formula in the main report to display the shared stringvar I get the first record blank and all the rest “Y”. What should I be doing to get the shared stringvar to display on the detail line of the main report correctly?

WhilePrintingRecords;
shared StringVar Pension

I need the Shared Variable to be able to use the result in main report formulas such as:
if {EMP_JOB.GROUPCD} = "ONAP" and {@Stringvar Pension} = "Y" then .13 else
if {EMP_JOB.GROUPCD} = "ONAP" and {@Stringvar Pension} = "N" then .09

Your assistance is greatly appreciated.
 
Change this formula:

WhilePrintingRecords;
shared stringVar Pension;
if isnull ({@Pension}) then
Pension := "N" else
Pension := {@Pension};

-LB
 
I now have the correct value but the first record is blank and each next record seems to have the above records value.
Jane Shared StringVar Y but Main report Displays blank
John Shared StrinVar N but Main report Diplays Y (Jane correct value)

This continues through the entire report?
 
The subreport must be in a section above the one in which it is referenced, so that if the sub is in GH1_a, the main report fields must be in GH1_b.

-LB
 
I did check and there is only one detail line not multiples in both the main and subreport?
 
If you are referencing the shared variable in the detail section, then insert another detail section. The sub should be in detail_a and the shared variable formula in detail_b. You can format detail_a to "underlay following sections" if you are showing content from the sub. There are also ways to make it disappear (and the section it is in) if you aren't displaying anything directly.

-LB
 
That worked perfectly. Thank you for your time and expertise. If I wanted this to not show on the report how would that be done? I notice if I suppress my formulas based on the shared variable do not calculate.
 
Suppress all sections WITHIN the subreport, and in the main report, select the subreport->right click->format subreport->subreport tab->check "suppress blank subreport". Then in the section expert check "suppress blank section" for detail_a, where the sub is located. What you CANNOT do, is suppress the subreport object directly or suppress or hide the section containing the sub.

-LB
 
Thank you again that is quite the round about way to get there :)
I would have never followed that through.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top