Printing multiple sums in GroupHeader
Hello,
according to the manual it is possible to print a sum in a group header by using double pass like this:
And this actually works. But how can I calculate multiple sums in the GroupHeader? Obviously, I cannot use the same variable as it would overwrite the other value. So I tried adding a new variable. It looks like this now:
But this does not work as expected. It always prints the sum of the previous group. Why is that? How can I use multiple sums in a group header correctly?
according to the manual it is possible to print a sum in a group header by using double pass like this:
procedure GroupHeader1OnBeforePrint(Sender: TfrxComponent);
begin
if Engine.FinalPass then
Memo8.Text := 'Sum: ' + Get(<Group."CustNo">);
end;
procedure GroupFooter1OnBeforePrint(Sender: TfrxComponent);
begin
Set(<Group."CustNo">,
FloatToStr(SUM(<Group."ItemsTotal">,MasterData1)));
end;
begin
end.
And this actually works. But how can I calculate multiple sums in the GroupHeader? Obviously, I cannot use the same variable as it would overwrite the other value. So I tried adding a new variable. It looks like this now:
procedure GroupHeader1OnBeforePrint(Sender: TfrxComponent);
begin
if Engine.FinalPass then
Memo8.Text := 'Sum: ' + Get(<Group."CustNo">);
Memo9.Text := 'Sum: ' + Get(<test>);
end;
procedure GroupFooter1OnBeforePrint(Sender: TfrxComponent);
begin
Set(<Group."CustNo">,
FloatToStr(SUM(<Group."ItemsTotal">,MasterData1)));
Set(<test>,
FloatToStr(SUM(<Group."SomeOtherValue">,MasterData1)));
end;
begin
end.
But this does not work as expected. It always prints the sum of the previous group. Why is that? How can I use multiple sums in a group header correctly?
Comments
at script start
var ar: TfrxArray;
in the empty begin endblock of sctript
ar := TfrxArray.Create;
in the appropriate band set the valueof the array
ar[(<Group."CustNo">] := FloatToStr(SUM(<Group."SomeOtherValue">,MasterData1));
But anyway, at least it works now. Thank you.
I have got one more similar question. Is it also possible to print sums in Header?
edit: sorry. you don't need to answer that. of course it works the same way.