We help IT Professionals succeed at work.

Passing a value calculated in subreport back to main report

Larry Rungren
on
in sub report  formula a =
WhilePrintingRecords;
Shared numbervar registrationscp := Sum ({@cpreg});

in mainline report formula b =
WhilePrintingRecords;
Shared NumberVar registrationscp;

If I put the formula on the main report page always 0???
Comment
Watch Question

Senior Consultant
Most Valuable Expert 2011
Top Expert 2013
Commented:
WHere are the formulas in reference to each other,

The one in the main report must be in the report in a section after the subreport.

Also, I have found that you need to declare the shared variable in the main report header so it knows about it before the subreport is run.

I have also found that it is usually better to do the assignments in a separate statement rather than in the declaration.

mlmcc
Larry RungrenDirector of Technology

Author

Commented:
the formulas are as you describe position wise.
I'm not sure what you mean in your last statement

 have also found that it is usually better to do the assignments in a separate statement rather than in the declaration.
??
Larry RungrenDirector of Technology

Author

Commented:
Subreport was in middle of a section.  Once I moved it outside and in fron of the section all is OK  Thanks.
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
What I meant is

Use
WhilePrintingRecords;
Shared numbervar registrationscp;
registrationscp := Sum ({@cpreg});

mlmcc
Larry RungrenDirector of Technology

Author

Commented:
I see waht you mean.  I appreciate the additional comment.  This will come in handy for some very complex reports with subreports that accoumulate totals completely differently than the main line.