Create Memo and calculate the SUM with code (script)
I have this script code to create my report in the runtime
After showing the report All work fine but in the PageFooter1 and ReportSummary1 all Memo are Empty (no Totals)
Note: I am using a Memory Table (TFDMemoTable) in TdataModule form.
Please, Help me to solve this problem.
All suggestions are welcome.
                                 Â
procedure Page1OnBeforePrint(Sender: TfrxComponent);
var
i, L1, L2: integer;
L: extended;
S: string;
begin
L1 :=0;
while not FDQuery1.eof do
begin
inc(L1);
FDQuery1.next;
end;
  L2 :=0;
while not FDQuery2.eof do
begin
inc(L2);
FDQuery2.next;
end;
L := 1200/(L1+L2);
i :=0;
FDQuery1.first;
while not FDQuery1.eof do
begin
inc(i);
S := FDQuery1.FieldByName('FieldValue').AsString;
BuiltMemo('nMemo'+ inttostr(i),<FDQuery1."FieldName">,12, 30, L, GroupHeader1, False);
BuiltMemo('vMemo'+ inttostr(i),'[<MemTable."'+S+'">]',0, 28, L, MasterData1, True);
BuiltMemo('sMemo'+ inttostr(i),'[SUM(<MemTable."'+S+'">,MasterData1)]',4, 18, L, PageFooter1, True);
BuiltMemo('tMemo'+ inttostr(i),'[SUM(<MemTable."'+S+'">,MasterData1)]',4, 18, L, ReportSummary1, True);
FDQuery1.next;
FDQuery2.first;
while not FDQuery2.eof do
begin
inc(i);
S := FDQuery2.FieldByName('FieldValue').AsString;
BuiltMemo('nMemo'+ inttostr(i),<FDQuery2."FieldName">,12, 30, L, GroupHeader1, False);
BuiltMemo('vMemo'+ inttostr(i), '[<MemTable."'+S+'">]',0, 28, L, MasterData1, True);
BuiltMemo('sMemo'+ inttostr(i),'[SUM(<MemTable."'+S+'">,MasterData1)]',4, 18, L, PageFooter1, True);
BuiltMemo('tMemo'+ inttostr(i),'[SUM(<MemTable."'+S+'">,MasterData1)]',4, 18, L, ReportSummary1, True);
FDQuery2.next;
end;
end;
procedure BuiltMemo(Name, Text: string; Top, Height, Width: Extended; Parent: TfrxBand; IsCurrency: boolean);
var
Memo: TfrxMemoView;
begin
Memo := TfrxMemoView.create(parent);
Memo.name := name;
Memo.Text := Text;
Memo.top := top;
Memo.Height := height;
Memo.Width := width;
memo.halign := hacenter;
memo.valign := vacenter;
Memo.Align := baRight;
Memo.HideZeros := True;
if IsCurrency then
begin
Memo.DisplayFormat.FormatStr := '%2.2m';
Memo.DisplayFormat.Kind := fkNumeric;
end;
end;
After showing the report All work fine but in the PageFooter1 and ReportSummary1 all Memo are Empty (no Totals)
Note: I am using a Memory Table (TFDMemoTable) in TdataModule form.
Please, Help me to solve this problem.
All suggestions are welcome.
Comments
By putting the code between
begin
end.
Not in the function (page1OnBeforePrint).
Thanks for all