Recent

Author Topic: Lareport | Sum a memo with calculated field  (Read 4356 times)

cpalx

  • Hero Member
  • *****
  • Posts: 619
Lareport | Sum a memo with calculated field
« on: June 16, 2016, 06:13:13 pm »
Hello

i have in a report a Memo where i have a script

if [roQry."emi"] = [DATE] then
    text:= [roQry."total"]
else
    text:= [ 0.00 ]   

how can I have the sum of this memo?

alexs75

  • Full Member
  • ***
  • Posts: 104
Re: Lareport | Sum a memo with calculated field
« Reply #1 on: June 16, 2016, 08:06:00 pm »
on ReportTitle band script:
Code: Pascal  [Select]
  1. fsum:=0;
  2.  
On you memo script:

Code: Pascal  [Select]
  1. if [roQry."emi"] = [DATE] then
  2. begin
  3.     text:= [roQry."total"];
  4.     fsum:=fsum +  [roQry."total"];
  5. end
  6. else
  7.     text:= [ 0.00 ]  
  8.  

And show [fsum]

cpalx

  • Hero Member
  • *****
  • Posts: 619
Re: Lareport | Sum a memo with calculated field
« Reply #2 on: June 16, 2016, 10:03:35 pm »
works,

thank you very much
« Last Edit: June 16, 2016, 11:05:26 pm by cpalx »

Graeme

  • Hero Member
  • *****
  • Posts: 1430
    • Graeme on the web
Re: Lareport | Sum a memo with calculated field
« Reply #3 on: June 16, 2016, 10:50:49 pm »
Instead of scripts, can you not use event handlers?
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

cpalx

  • Hero Member
  • *****
  • Posts: 619
Re: Lareport | Sum a memo with calculated field
« Reply #4 on: June 16, 2016, 11:05:40 pm »
How?

Graeme

  • Hero Member
  • *****
  • Posts: 1430
    • Graeme on the web
Re: Lareport | Sum a memo with calculated field
« Reply #5 on: June 17, 2016, 01:30:10 pm »
Scrap that idea! Unlike most other reporting solutions, LazReport has near zero useful report element event handlers.

I was thinking in terms of events like Memo.OnBeforePrint, Memo.OnGetValue etc. But it seems LazReport has none of those.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

alexs75

  • Full Member
  • ***
  • Posts: 104
Re: Lareport | Sum a memo with calculated field
« Reply #6 on: June 17, 2016, 02:05:44 pm »
Graeme:
This report not need recompile main program. all code in report script.

If you use Memo.OnBeforePrint, Memo.OnGetValue  - need recompile project.

Graeme

  • Hero Member
  • *****
  • Posts: 1430
    • Graeme on the web
Re: Lareport | Sum a memo with calculated field
« Reply #7 on: June 20, 2016, 03:13:30 pm »
Using reporting scripts have both pros and cons. In all cases, the cons are always that the reporting script has limited functionality. By using events handlers you have the full support of what the Object Pascal language (RTL, FCL and any other libraries) have to offer.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

alexs75

  • Full Member
  • ***
  • Posts: 104
Re: Lareport | Sum a memo with calculated field
« Reply #8 on: June 20, 2016, 03:23:48 pm »
LazReport very good work with db data.
In 90% report not need rtl/fcl.
for 10% i'm add user functions.