Forum > LazReport

[SOLVED]Using SUM function with variables

<< < (3/3)

[SOLVED]As I was not able to compile your project, I put Lazarus 2.2.0 on another computer and now i can see your project, which works without a itch.

I see you don't use any memo format in lazreport. Also, your variables are not defined in Lazreport variables.

So I tried to mimic your setup in my regular installation (Lazarus 2.0.0) (no variables, no formats, function dealing with decimal separator), and guest what? Still same problem.

Next step: migrate my program to LAZARUS 2.2.0 (lot of packages to install...). Be back with follow up soon.

2022/03/31: Migration completed. No modifications needed. The report still doesn't calculate SUM.

The strange thing is other report in the same application can calculate SUM, with the same type of report: Report title, Group Header, Master Data, Group Footer and Report summary, no variables.

So it's obviously something in my code.
2022/04/01: I found it. In my «OnGetValue» procedure, i use a «Case» statement to fetch value from the stringgrid to report.

As I experienced program exit without notice coming from this procedure, I put a «Else» statement at the end of case («Else ParValue := '0'»), which prevents the program to exit.

This is why the SUM formulas in my report were not calculated. I suppose LazReport parser calculates formulas when no variable ou field is present. With the «Else» statement, I bypass this process.

Now, my SUM works like it was supposed to be. But... only for some records in the stringgrid.

Effectively, if I ask for a list of all transactions for my report, the program hangs somewhere, surely because a value in the stringgrid is not compatible with numeric or boolean. The date values are in string format («2022/03/05»), and I'm pretty sure strings values are not a problem. So I will checks and corrects numeric and boolean values in the stringgrid before transferring them to report with the ParValue statement.


[0] Message Index

[*] Previous page

Go to full version