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

Subtotal a variable

Status
Not open for further replies.

mdtimo

Programmer
Oct 18, 2001
38
US
I pass a variable(numbervar) from my subreport to the detail of my master report. I then want to subtotal this variable in my master report. But unlike other fields or formulas I can not subtotal on the variable.

Is there a way around this?
 
You'll have to manually do so in a formula, use the 3 step formula approach:

Place this in the report header and suppress it:
//@initSVsum;
whileprintingrecords;
global numbervar SVSum :=0

Place this after the shared variable is returned and suppress it:

//@IncrementSVSum
whileprintingrecords;
shared numbervar mysharedvar;
global numbervar SVSum;
SVSum := SVSum+mysharedvar

//@DisplaySVSum
whileprintingrecords;
global numbervar SVSum;
SVSum

Seems right anyway...

-k kai@informeddatadecisions.com
 
I oversimplified my question.

I use the variable in a formula.

IF table.value="A" then variablefromsubreport else 0

This is the value I want to subtotal on.

Your logic seems good to me but I don't think it applies in this situation.
 
I don't understand how this differs, except that you might need to qualify when it's summed:

Place this in the report header and suppress it:
//@initSVsum;
whileprintingrecords;
global numbervar SVSum :=0

Place this after the shared variable is returned and suppress it:

//@IncrementSVSum
whileprintingrecords;
shared numbervar mysharedvar;
global numbervar SVSum;
If table.value="A" then
SVSum := SVSum+mysharedvar

//@DisplaySVSum
whileprintingrecords;
global numbervar SVSum;
SVSum

Same rules apply, it just gets incremented when your logic is met.

-k kai@informeddatadecisions.com
 
vampire...

i am guessing it is not possible for this to work when you are resetting your variable to 0 in the groupfooter each time; is there another way to subtotal them in that case?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top