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

Multiple PreviewForms from one TppReport?

edited June 2002 in General
Hello team Report Builder:

I have a D6 form with logic to select parameters for a TppReport, myReport.
myReport.PreviewFrom is an MDI form. When it is open I can go back to the
form with the logic and select a new form.

If myReport.PreviewForm is present asking for a second myReport.Print does
nothing.

To be cautious I do "if assigned(myReport.PreviewForm) then
myReport.PreviewForm.Close;" before doing myReport.Print.

First question: Can a single TppReport have several PreviewForms?
Second question: If not, is my check "if assigned(...) ..." correct?

Thanks

Russell Belding

Comments

  • edited June 2002
    You should be able to preview a report with two preview forms but this
    hasn't been tested. Assigned will check to see if the object reference is
    non nil. Does this work or are you getting AV's? You should cancel the
    preview process if you want the preview form to be closed. For example, if
    I have a report preview being shown non-modally, I can click another button
    to stop the current preview and close the active preview form.

    uses
    ppViewr;

    procedure TForm1.btnPrintClick(Sender: TObject);
    begin
    ppReport1.Print;
    end;

    procedure TForm1.btnPreviewCloseClick(Sender: TObject);
    begin
    TppViewer(ppReport1.PreviewForm.Viewer).Cancel;
    ppReport1.PreviewForm.Close;
    end;


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited June 2002
    Thanks Jim for your reply.

    I am not getting errors when I use code
    if assigned(ppReport1.PreviewForm) then
    begin
    TppViewer(ppReport1.PreviewForm.Viewer).Cancel; // haven't used this yet
    but see its necessary
    ppReport1.PreviewForm.Close;
    Application.ProcessMessages; // necessary to put up a new form immediately
    end;

    // put up the new form

    Regards

    Russell


This discussion has been closed.