Home RAP
New Blog Posts: Merging Reports - Part 1 and Part 2

Updating data with RAP after print to file

Hi,
Delphi Berlin
RB 19

i use to execute SQL update in the Report.AfterPrint event
when the end-user print to file the report

but the report is first preview on the screen by the end_user
so he have to click the print button in the top left corner of the preview screen

so the Report.AfterPrint event fire one time when screen preview
and two time when the end-user print to file

so in RAP, i must ignore the first time like this :

procedure ReportAfterPrint;
begin
if bDataFound and (Report.DeviceType=dtPrinter) and (Report.AutoSearchFields[0].SearchExpression='0') then
begin
{update mytable where ...}
end;
end;

before RB 18 it work fine because the first time Report.DeviceType='Sreen' and in the second time Report.DeviceType='Printer'

Since RB18 in both cases Report.DeviceType='Printer'.

is there a better way to update my data after the end-user had generate the text file ?

Comments

  • Hi Julien,

    I'll research improving this for RB 20, it requires some re-design.

    For now I recommend the following:

    - Use RAP Global Declarations Variables to define

    var
    gbPrintToFile: Boolean;
    - implement RAP Report BeforePrint and AfterPrint events like this

    procedure ReportBeforePrint;
    begin
    gbPrintToFile := Report.FileDevice <> nil;

    if gbPrintToFile then
    ShowMessage('RAP BeforePrint - print to file');
    end;

    procedure ReportAfterPrint;
    begin
    if gbPrintToFile then
    ShowMessage('RAP AfterPrint - print to file');
    end;

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
Sign In or Register to comment.