Reputation: 75
So, I have a table in database like this :
number varchar2 (50)
activities varchar2 (50)
value number
flag varchar(2)
for flag
, I have 2 options which means :
1=debit and 2=credit.
assume I wanted to create a report using fastreport 4, I'll make the report look like this :
my question is, how do you code in fastreport so that every value with flag 1 will show up in debit column and value with flag 2 shows up in credit column? I am using delphi 7 by the way. Thanks!
Upvotes: 0
Views: 2779
Reputation: 29933
One possible solution is to use band's OnBeforePrint
event:
procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
begin
if <reportdataset."FLAG"> = '1' then begin
MemoDebit.Text := FormatFloat('#0.00', <reportdataset."VALUE">);
MemoCredit.Text := FormatFloat('#0.00', 0);
end
else if <reportdataset."FLAG"> = '2' then begin
MemoDebit.Text := FormatFloat('#0.00', 0);
MemoCredit.Text := FormatFloat('#0.00', <reportdataset."VALUE">);
end
else begin
MemoDebit.Text := FormatFloat('#0.00', 0);
MemoCredit.Text := FormatFloat('#0.00', 0);
end;
end;
Upvotes: 1
Reputation: 4127
FastReport can include an IIF statement in a TfrxMemoView.
Your report band will include two fields, one for the Debit column and one for the credit column.
Then in the debits field, you will enter:
[IIF(<Data."flag"> = '1', <Data."value">, '')]
And in the credits field:
[IIF(<Data."flag"> = '2', <Data."value">, '')]
The IIF statement can also be used inside a Sum() call in footers to get the correct totals.
[SUM(IIF(<Data."flag"> = '1', <Data."value">, 0))]
Upvotes: 0