Forum > LazReport

[SOLVED]Using SUM function with variables

(1/3) > >>

Guylain:
I have a report fetching values from a stringgrid using the OnGetValue event. The report has a header, one MasterData and a Group.
I use variables declared in report, and values from the stringgrid appear for each row.

So far so good, but the SUM function with those variables in the GroupFooter shows nothing. The Text Memo looks like this:  [[SUM([InvoiceAmount])]. Of course, the MasterData band is linked to a frUserDataSet.

I use SUM function usually with database fields with no problem. My question is: Is the SUM function working only with fields?

korba812:
Generally aggregate functions should work with TfrUserDataset. Do you have all 3 events implemented (OnCheckEOF, OnFirst, OnLast)?

Also try with the extra parameter with band name:
[SUM([InvoiceAmount], 'MasterData1')]

Guylain:
Yes, these 3 events are as usual for a StringGrid:
EOF->   Eof := FRow = (Form1.SG_Data.RowCount-1);
First: FRow := 1
Next: FRow := Inc(FRow)
My StringGrid has 1 fixed row.

korba812:
How do you get value from TStringGrid? Do you convert string to number or just pass string? Can you show OnGetValue implementation?

Guylain:
I include some picture explaining the process.
1. The data is fetched from some DBF files into the stringgrid. I use FloatToStrF function to format numeric values.
2. My system works with the ',' decimal separator, so I tried to change to '.' with same result.
3. The OnGetValue function uses declared report variables to obtain values. I use a Case statement.
4. The report shows very well the row values, but not the totals

Navigation

[0] Message Index

[#] Next page

Go to full version