Change printed Text at runtime - Fastreport

Hello everyone,

when loading a fastreport, preparing the report and try to print, the value of the datasetfields are filled in the event afterdata. I would like to change the results of the databasefields at runtime without using fastscript. Because frxReport1 doesn't have the event afterdata, I tried all events attached to frxReport1 and the only one, that has already the result of the datasetfields is frxReport1AfterPrint(Sender: TfrxReportComponent). That's why, I tried this one. The Problem is, that it runs into the 
event, displays the right value, makes the changes, but the changes are not displayed in preview or on the printer.

procedure TForm1.frxReport1AfterPrint(Sender: TfrxReportComponent);
var
   text : widestring;
begin
   if ((Sender is TfrxMemoView) and (Sender.Name = 'Memo1')) then begin
      //Memo1 normally has [Query1."Fieldname1"]
      text := TfrxMemoView(sender).Lines.Text;
      //Now Memo1 is set with the value of the Datasetfield
      //This value of the databasefield I want to change now
      TfrxMemoView(sender).Lines.Text := text + 'asdf';
   end;
end;

Can anybody help me please? I've tried for several days now, but it won't work.

Thank you very much!

Klaus Demetz-Schittek
1
Klaus
2/5/2010 10:51:03 AM
embarcadero.delphi.reporting 487 articles. 0 followers. Follow

2 Replies
10813 Views

Similar Articles

[PageSpeed] 15

Dear Klaus Demetz-Schittek!

You should use Report.PreviewPages.ModifyPage(PageIndex, Page) function if 
you change object properties in afterprint event.

or example
 page:=   frxReport.PreviewPages.CurPage;
 Report.PreviewPages.ModifyPage(PageIndex, Page)


"Klaus Demetz-Schittek" wrote: news:210881@forums.codegear.com...
> Hello everyone,
>
> when loading a fastreport, preparing the report and try to print, the 
> value of the datasetfields are filled in the event afterdata. I would like 
> to change the results of the databasefields at runtime without using 
> fastscript. Because frxReport1 doesn't have the event afterdata, I tried 
> all events attached to frxReport1 and the only one, that has already the 
> result of the datasetfields is frxReport1AfterPrint(Sender: 
> TfrxReportComponent). That's why, I tried this one. The Problem is, that 
> it runs into the
> event, displays the right value, makes the changes, but the changes are 
> not displayed in preview or on the printer.
>
> procedure TForm1.frxReport1AfterPrint(Sender: TfrxReportComponent);
> var
>   text : widestring;
> begin
>   if ((Sender is TfrxMemoView) and (Sender.Name = 'Memo1')) then begin
>      //Memo1 normally has [Query1."Fieldname1"]
>      text := TfrxMemoView(sender).Lines.Text;
>      //Now Memo1 is set with the value of the Datasetfield
>      //This value of the databasefield I want to change now
>      TfrxMemoView(sender).Lines.Text := text + 'asdf';
>   end;
> end;
>
> Can anybody help me please? I've tried for several days now, but it won't 
> work.
>
> Thank you very much!
>
> Klaus Demetz-Schittek

-- 
Best regards,
 Michael Philippenko    mailto:michael@fast-report.com
 Fast Reports - reporting must be Fast!
 http://www.fast-report.com
0
Michael
2/5/2010 12:51:23 PM
> {quote:title=Michael Philippenko wrote:}{quote}
> Dear Klaus Demetz-Schittek!
> 
> You should use Report.PreviewPages.ModifyPage(PageIndex, Page) function if 
> you change object properties in afterprint event.
> 
> or example
>  page:=   frxReport.PreviewPages.CurPage;
>  Report.PreviewPages.ModifyPage(PageIndex, Page)
> 
> 
> "Klaus Demetz-Schittek" wrote: news:210881@forums.codegear.com...
> > Hello everyone,
> >
> > when loading a fastreport, preparing the report and try to print, the 
> > value of the datasetfields are filled in the event afterdata. I would like 
> > to change the results of the databasefields at runtime without using 
> > fastscript. Because frxReport1 doesn't have the event afterdata, I tried 
> > all events attached to frxReport1 and the only one, that has already the 
> > result of the datasetfields is frxReport1AfterPrint(Sender: 
> > TfrxReportComponent). That's why, I tried this one. The Problem is, that 
> > it runs into the
> > event, displays the right value, makes the changes, but the changes are 
> > not displayed in preview or on the printer.
> >
> > procedure TForm1.frxReport1AfterPrint(Sender: TfrxReportComponent);
> > var
> >   text : widestring;
> > begin
> >   if ((Sender is TfrxMemoView) and (Sender.Name = 'Memo1')) then begin
> >      //Memo1 normally has [Query1."Fieldname1"]
> >      text := TfrxMemoView(sender).Lines.Text;
> >      //Now Memo1 is set with the value of the Datasetfield
> >      //This value of the databasefield I want to change now
> >      TfrxMemoView(sender).Lines.Text := text + 'asdf';
> >   end;
> > end;
> >
> > Can anybody help me please? I've tried for several days now, but it won't 
> > work.
> >
> > Thank you very much!
> >
> > Klaus Demetz-Schittek
> 
> -- 
> Best regards,
>  Michael Philippenko    mailto:michael@fast-report.com
>  Fast Reports - reporting must be Fast!
>  http://www.fast-report.com

Thank you very much! It works!

Klaus
1
Klaus
2/10/2010 5:45:40 PM
Reply: