Page 1 of 2
Running Sum
Posted: Mon Aug 13, 2007 1:32 am
by Chan Kuan Leang
Hi,
Can I know how to do a running sum in Databand?
For example header "No, ItemID, ...
The "No" will add by itself starting from 1, 2 & so on.
hope you can understand.
Thanks.
Running Sum
Posted: Mon Aug 13, 2007 1:43 am
by EDV Gradl
One way to do it is like this:
Add a variable of type int to the report, start value is 0, lets say it is called MySum
Edit the RenderingEvent of the databand and add
MySum++;
Now you can print this sum in the databand:
{this.MySum}
I hope that helps.
Marco
Running Sum
Posted: Mon Aug 13, 2007 2:01 am
by Chan Kuan Leang
EDV wrote:One way to do it is like this:
Add a variable of type int to the report, start value is 0, lets say it is called MySum
Edit the RenderingEvent of the databand and add
MySum++;
Now you can print this sum in the databand:
{this.MySum}
I hope that helps.
Marco
Thanks. It helps.
What about in GroupheaderBand?? Is it the same?
I have test it in groupheaderband, but instead of appearing 1,2,3... it appears as 1,2,5,13 & so on.
Thanks.
Running Sum
Posted: Mon Aug 13, 2007 2:06 am
by EDV Gradl
Correct berhaivor. The variable increments by on for every data row.
For use in Group Headerband, you need a second variable MySumGroup and you should you the rendering event of the group for the new variable.
Thanks, Marco
Running Sum
Posted: Mon Aug 13, 2007 5:10 am
by Chan Kuan Leang
EDV wrote:Correct berhaivor. The variable increments by on for every data row.
For use in Group Headerband, you need a second variable MySumGroup and you should you the rendering event of the group for the new variable.
Thanks, Marco
Thanks for your help.
But, i seems not able to get the desired results.
I have try as below
Add a variable of type int to the report, start value is 1, & named it as MyGroupSum
Edit the RenderingEvent of the GroupHeaderBand and add
MyGroupSum++;
In the GroupHeaderBand:
{this.MyGroupSum}
But, the result is still the same... 1, 3, 4, 5....
Can you help on this? Thanks
Running Sum
Posted: Mon Aug 13, 2007 5:24 am
by EDV Gradl
Hmm, it seem that the event is called every timer, even if the Band is not printed.
I would try BeforePrint of the groupband or
BeforePrint of the text component inside the group band.
Let me know if it works..
Marco
Running Sum
Posted: Mon Aug 13, 2007 5:28 am
by Chan Kuan Leang
EDV wrote:Hmm, it seem that the event is called every timer, even if the Band is not printed.
I would try BeforePrint of the groupband or
BeforePrint of the text component inside the group band.
Let me know if it works..
Marco
Thank you so much!!!
It is working now.!! Finally!!!
:biggrin:
Running Sum
Posted: Thu Sep 06, 2007 10:23 am
by Chan Kuan Leang
I have to to create the running sum again in the databand. But I failed using the same method as below in the post.
I do not know what wrong's with it.
It keeps giving errors as below
Code: Select all
Exception Details: System.Exception: C:\Documents and Settings\Chan Kuan Leang\Local Settings\Temp\d-gnyqzn.0.vb(57,0) : warning BC40004: variable 'Unit' conflicts with property 'Unit' in the base class 'StiReport' and should be declared 'Shadows'.C:\Documents and Settings\Chan Kuan Leang\Local Settings\Temp\d-gnyqzn.0.vb(201,0) : error BC30454: Expression is not a method.C:\Documents and Settings\Chan Kuan Leang\Local Settings\Temp\d-gnyqzn.0.vb(201,0) : error BC30800: Method arguments must be enclosed in parentheses.C:\Documents and Settings\Chan Kuan Leang\Local Settings\Temp\d-gnyqzn.0.vb(201,0) : error BC30037: Character is not valid.
Please help me on that.
Running Sum
Posted: Thu Sep 06, 2007 10:34 am
by EDV Gradl
Is your variable called 'unit'?
Try changing that name, cause unit is already a member in the StiReport Class.
Marco
Running Sum
Posted: Fri Sep 07, 2007 11:55 am
by Chan Kuan Leang
EDV wrote:Is your variable called 'unit'?
Try changing that name, cause unit is already a member in the StiReport Class.
Marco
Code: Select all
C:\Documents and Settings\Chan Kuan Leang\Local Settings\Temp\fs3mds9m.0.vb(197,0) : error BC30454: Expression is not a method.
C:\Documents and Settings\Chan Kuan Leang\Local Settings\Temp\fs3mds9m.0.vb(197,0) : error BC30800: Method arguments must be enclosed in parentheses.
C:\Documents and Settings\Chan Kuan Leang\Local Settings\Temp\fs3mds9m.0.vb(197,0) : error BC30037: Character is not valid.
Hmm.. I have rename my textbox. But, it comes up with the above errors.
Please help on that.
I created a variable "MySum" int, Default Value = 0
Then in the databand, I have tried putting MySum++; in Before Render or Rendering Events & Before Print, it still comes up with the same errors.