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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I Count Subreports 1

Status
Not open for further replies.

chrisgeek

Technical User
Joined
Oct 16, 2008
Messages
25
Location
US
I need a count for a census. I have the subreport located in a group header which is supressed when blank. I am calculating my general data already but need to count the sub reports so that I can determine what percentage of people have data returned by the subreport. Any help you can provide will be greatly appreciated.
 
Add a shared Var formula to report footer of SUbReport that increments every time it executes

@SrCount
WhilePrintingrecords;

Shared Numbervar SRCount:= SRCount+1

In Main Report Header
@InitSRCount

WhilePrintingrecords;

Shared Numbervar SRCount:=0;


In Main Report footer
@DisplaySRCount

WhilePrintingrecords;

Shared Numbervar SRCount;

Ian
 
I think the sub will execute for each group section--whether or not it returns results, so the number of subs is the distinctcount of the group field. To then determine what percentage are not blank, you need to use a shared variable in the subreport footer:

whileprintingrecords;
shared numbervar ID := maximum({table.ID});//some recurring unique ID field

In the main report group header_a section (with the sub in GH_b), add a reset formula:

whileprintingrecords;
shared numbervar ID := 0;

In the main report group footer section, add a formula:

whileprintingrecords;
shared numbervar ID;
numbervar cnt;
if ID <> 0 then
cnt := cnt + 1;

Then in the report footer, use a formula like this:

whileprintingrecords;
numbervar cnt;
cnt % distinctcount({table.groupfield})

-LB
 
Thanks for the help. The subreport does execute regardless of it being blank or not. Which is what the calculation returned. I used LBass's suggestion and it worked perfectly. Thanks for your help I wouldn't have figured this one out on my own!
 
Thanks again for the help. I have a slightly different question for this problem.

Instead of a percentage that isn't blank how would I go about just displaying a count of the subreports containing data. I'd like to compare that with the grand total rather than a percentage.
 
Just add this formula to the report footer for a count of the non-blank subreports:

whileprintingrecords;
numbervar cnt;

-LB
 
Thanks again LBass! Exactly what I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top