Summing a Memo TfrxMemoView
Hi,
I have a budget style report with a number of columns and the value displayed in the Report field can vary based on the period range selected by the user.
So for each detail the value is calculated using the following statement, in the OnBeforePrint event
I was hoping that I could use the SUM() function to sum the values from the object QtyActual and place in to my group Footer and one for Report Total, but can not seem to get a value to return, tried QtyActual.Memo.Text (which I didn't expect to work) and QtyActual.Value
So the only way I can see (at the moment) to get a sub-total is to use a variable that increases the calculate value after each detail line is printed...
i.e.
Then in my group footer, I have another field that is sent on the OnBeforePrint event
It works OK, but I have a number of columns to repeat this for, and was wondering if I am missing some very simple and obvious way of using the SUM function on a TfrxMemoView component...
Any simple method, would be much appreciated...
Regards
Simon
PS: Coming from crystal reports where you create a formula, stick it on a report and right click sum, I have become very lazy
I have a budget style report with a number of columns and the value displayed in the Report field can vary based on the period range selected by the user.
So for each detail the value is calculated using the following statement, in the OnBeforePrint event
var
aValue : Double;Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
begin
aValue := 0;
if 1 in [<Start_Month>..<End_Month>] then aValue := aValue + <dbAccumBudget."ACTUALLASTQTY01">;
if 2 in [<Start_Month>.. <End_Month>] then aValue := aValue + <dbAccumBudget."ACTUALLASTQTY02">;
if 3 in [<Start_Month>..<End_Month>] then aValue := aValue + <dbAccumBudget."ACTUALLASTQTY03">;
if 4 in [<Start_Month>..<End_Month>] then aValue := aValue + <dbAccumBudget."ACTUALLASTQTY04">;
if 5 in [<Start_Month>.. <End_Month>] then aValue := aValue + <dbAccumBudget."ACTUALLASTQTY05">;
if 6 in [<Start_Month>.. <End_Month>] then aValue := aValue + <dbAccumBudget."ACTUALLASTQTY06">;
if 7 in [<Start_Month>..<End_Month>] then aValue := aValue + <dbAccumBudget."ACTUALLASTQTY07">;
if 8 in [<Start_Month>..<End_Month>] then aValue := aValue + <dbAccumBudget."ACTUALLASTQTY08">;
if 9 in [<Start_Month>..<End_Month>] then aValue := aValue + <dbAccumBudget."ACTUALLASTQTY09">;
if 10 in [<Start_Month>..<End_Month>] then aValue := aValue + <dbAccumBudget."ACTUALLASTQTY10">;
if 11 in [<Start_Month>..<End_Month>] then aValue := aValue + <dbAccumBudget."ACTUALLASTQTY11">;
if 12 in [<Start_Month>..<End_Month>] then aValue := aValue + <dbAccumBudget."ACTUALLASTQTY12">;
if 13 in [<Start_Month>..<End_Month>] then aValue := aValue + <dbAccumBudget."ACTUALLASTQTY13">;
                                                         Â
if 14 in [<Start_Month>..<End_Month>] then aValue := aValue +<dbAccumBudget."ACTUALQTY01">;Â Â
if 15 in [<Start_Month>..<End_Month>] then aValue := aValue +<dbAccumBudget."ACTUALQTY02">;Â Â
if 16 in [<Start_Month>..<End_Month>] then aValue := aValue +<dbAccumBudget."ACTUALQTY03">;Â Â
if 17 in [<Start_Month>..<End_Month>] then aValue := aValue +<dbAccumBudget."ACTUALQTY04">;Â Â
if 18 in [<Start_Month>..<End_Month>] then aValue := aValue +<dbAccumBudget."ACTUALQTY05">;Â Â
if 19 in [<Start_Month>..<End_Month>] then aValue := aValue +<dbAccumBudget."ACTUALQTY06">;Â Â
if 20 in [<Start_Month>..<End_Month>] then aValue := aValue +<dbAccumBudget."ACTUALQTY07">;Â Â
if 21 in [<Start_Month>..<End_Month>] then aValue := aValue +<dbAccumBudget."ACTUALQTY08">;Â Â
if 22 in [<Start_Month>..<End_Month>] then aValue := aValue +<dbAccumBudget."ACTUALQTY09">;Â Â
if 23 in [<Start_Month>..<End_Month>] then aValue := aValue +<dbAccumBudget."ACTUALQTY10">;Â Â
if 24 in [<Start_Month>..<End_Month>] then aValue := aValue +<dbAccumBudget."ACTUALQTY11">;Â Â
if 25 in [<Start_Month>.. <End_Month>] then aValue := aValue +<dbAccumBudget."ACTUALQTY12">;Â Â
if 26 in [<Start_Month>.. <End_Month>] then aValue := aValue +<dbAccumBudget."ACTUALQTY13">;Â Â
                           Â
Grp2_ActualQty := Grp2_ActualQty + aValue;Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
qtyActual.Memo.Text := FormatFloat( '#,##0.00', aValue );
I was hoping that I could use the SUM() function to sum the values from the object QtyActual and place in to my group Footer and one for Report Total, but can not seem to get a value to return, tried QtyActual.Memo.Text (which I didn't expect to work) and QtyActual.Value
So the only way I can see (at the moment) to get a sub-total is to use a variable that increases the calculate value after each detail line is printed...
i.e.
Grp2_ActualQty := Grp2_ActualQty + aValue
Then in my group footer, I have another field that is sent on the OnBeforePrint event
  TotalG2ActualQty.Memo.Text := FormatFloat( '#,##0.00', grp2_ActualQty );
  grp2_ActualQty := 0;
It works OK, but I have a number of columns to repeat this for, and was wondering if I am missing some very simple and obvious way of using the SUM function on a TfrxMemoView component...
Any simple method, would be much appreciated...
Regards
Simon
PS: Coming from crystal reports where you create a formula, stick it on a report and right click sum, I have become very lazy
Comments
Read the user manual on groups and aggregates, aggregates must be used in the correct footer
also when using variables for intermediate values you may find declaring them at the start of the code page (global to all objects). declaring in side the procedure is local to procedure only
you can also write common procedures and link them to the event of object or band.
Don't think about how you did it in crystal.