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

Count Total From Sub-Report Variable Problem 1

Status
Not open for further replies.

reidtw

MIS
Feb 10, 2004
74
GB
Hi, getting confused about variables and searching the forum hasn't helped.

Working on CR8 to a SQL server.

I have a shared number variable where either 1 or 0 appears against an account code in the main report. I want to sum these to produce a total in the report footer. Here is some explanation of the reports: -

Sub-report: -

Linked by account to main report
//@VCOUNT
whileprintingrecords;
shared numbervar x:= if not isnull({@Account}) then 1 else 0;

Main Report: -
Grouped by account
My reset is in the group header
//@RESET
whileprintingrecords;
Shared Numbervar w:=0;

My variable is in the detail
//@COUNT
whileprintingrecords;
shared numbervar w;

I am happy that the reset and the visible 1 or 0 in the main report are correct but I cannot get a count total into the report footer - how does one do it?!?

Any help appreciated.

T

(I know you will probably say why not just have a record count if there is always going to be one record for each account; the answer is that the value of the variable can be 0 so I am looking to sum to show how many accounts are not in the sub report that are in the main report.)
 
If the subreport is in the group header section, e.g., GH_b, with the reset in GH_a, I would put the shared variable in GH_c, unless you are sure there is only one detail record per group. Anyway, change the display formula {@count} to:

whileprintingrecords;
shared numbervar w;
numbervar z := z + w;

Then in the report footer use a display formula like:

whileprintingrecords;
numbervar z;

Note that you used two different variable names in your post, and I'm assuming here that in all cases the variable name was meant to be "w".

-LB
 
Thanks lbass, that worked a treat.

You are correct to assume that the instances of the variable name should all be the same.

Thanks again.

T
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top