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!

Suppression, subreports and subtotals

Status
Not open for further replies.

mrmookster

Programmer
Feb 8, 2005
27
GB
I am using shared variables to calculate subtotals passed back from subreports in my main report BUT when a subreport is suppressed (v10) it still upgdtes the running total used to compute subtotals for the main report ... how can i stop the subtotal accumulating (uses last value) if the subreport is suppressed?

In group header
// reset
whileprintingrecords;
shared numbervar missingDays := 0;
global numbervar Totals :=0;


In detail (subreport section)
// accumulate
whileprintingrecords;
global numbervar Totals;
shared numbervar missingDays;
Totals := Totals + missingDays; // evaluates whether subreport printed or not

In group footer
// display subtotal
whileprintingrecords;
global numbervar Totals;
Totals


For example say I have 2 records returned for a particular group, but only one has data in the subreport Total = 20 (ie 10 + 10) it should only be 10
 
Use the same condition you used to suppress the subreport to suppress the running total
 
I'm using v10 so I didn't use a condition to suppress the subreport - I used the built in option suppress if blank
 
If the subreport is in the detail section, then you need to have the shared variable reset in a detail_a section (which can be suppressed), not in the group header. Create a separate reset formula for this.

-LB
 
Hi,
I feel particularly dumb today. I need to reset my variable also. But what syntax do I use? I want the variable to be zero if the subreport doesn't get any hits from the database.
Thanks
 
It would look something like this:

//{@reset }:
whileprintingrecords;
shared numbervar yourvariable := 0;

You would place this in the main report in a section above the one in which the subreport executes.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top