Dephi and Quickreport and you want to close the quickreport after printing [SOLVED]

Hi guys, just wanted to share a quicky solution for an age old problem of closing the quickreport after clicking the print button.

This feature allows the system to record all report generated report by the user without allowing them to reprint the same report again if the preview report is seen on the screen.

There are 2 parts to this solutions. 1 is function that will be called. 2 is the function to be called during the afterprint procedure in the quickreport

part 1 – function

procedure CloseAllReportPreviews;
var
  i: Integer;
begin
  try
    for i := Screen.FormCount - 1 downto 0 do
    if Screen.Forms[i].ClassName = 'TQRStandardPreview' then
    begin
      Screen.Forms[i].close;
    end;
  except
    ShowMessage('Please close all existing reports');
  end;
end;

part 2 – afterprint in quickreport

procedure TQuickReport.QuickRepAfterPrint(Sender: TObject);
begin
    CloseAllReportPreviews;
  end;
end;

Enjoy

Coffee Cup

Leave a Reply

Your email address will not be published. Required fields are marked *