Lazarus

Programming => Packages and Libraries => Topic started by: Wai-kit on September 23, 2020, 11:54:03 am

Title: LazReport OnGetValue question
Post by: Wai-kit on September 23, 2020, 11:54:03 am
Hi all,

I am using LazReport in my project and I want to format some values in the generated report. I think the obvious way is to use
the OnGetValue eventhandler. Unfortunately, ParValue (of type variant) is of value varEmpty each time OnGetValue gets called.
I discovered this by placing the code in the OnGetValue eventhandler:
Memo1.Lines.Add(Format('%s = %s', [ParName, ParValue]))

I do get the right values in my report, however the contents of Memo1 after showing the report shows that ParValue is empty.

Can anyone tell me what's happening here and is there a solution to this?
Thanks in advance.

Cheers,
Wai
Title: Re: LazReport OnGetValue question
Post by: eldonfsr on October 18, 2020, 01:30:48 am
You can put some thing like that

Code: Pascal  [Select][+][-]
  1. procedure TFormMain.frRepAttendGetValue(const ParName: String;
  2.   var ParValue: Variant);
  3. begin
  4.     if ParName ='NomCia' then begin
  5.       ParValue:= Formmain.SQLQCias.FieldByName('fcname').AsString;
  6.   end;
  7.   if ParName ='FullName' then begin
  8.         ParValue:= SQLQVacdR.FieldByName('lname').AsString+' '+SQLQVacdR.FieldByName('mname').AsString+' '+SQLQVacdR.FieldByName('fname').AsString ;
  9.   end ;
  10.   if ParName ='Status' then begin
  11.       if( SQLQVacdR.FieldByName('type2').AsString = 'A') then begin
  12.           ParValue:= 'Approved'
  13.       end;
  14.       if( SQLQVacdR.FieldByName('type2').AsString = 'R') then begin
  15.           ParValue:= 'Requested'
  16.       end;
  17.       if( SQLQVacdR.FieldByName('type2').AsString = 'D') then begin
  18.           ParValue:= 'Denied'
  19.       end;
  20.       if( SQLQVacdR.FieldByName('type2').AsString = '') then begin
  21.           ParValue:= 'Undefined'
  22.       end;
  23.   end;
  24. end;

you will receive the values you assign to ParValue

hope this hep you

[Edited to add code tags - please see How to Use the Forum (https://wiki.freepascal.org/Forum)]
TinyPortal © 2005-2018