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

Close

edited February 2002 in General
Testing my sample program with ReportBuilder, I came across a problem
(shall I say a bug with
RB), and found the fix.

I put a RB on a form. In run time view the form using the Print method.
Then close the project
without closing the form. Exception!!

Fix:

private
{ Private declarations }
prev_form_created : boolean;


procedure TMainForm1.FormCreate(Sender: TObject);
begin
DataModule2:= TDataModule2.Create(Application);
prev_form_created:= false;
DataModule2.AstaClientDataSet1.Active:= true
end;

procedure TMainForm1.PreviewFormCreate(Sender: TObject); // RB event
begin
prev_form_created:= true
end;

procedure TMainForm1.PreviewFormClose(Sender: TObject);
begin
prev_form_created:= false;
end;

procedure TMainForm1.FormCloseQuery(Sender: TObject; var CanClose:
Boolean);
begin
CanClose:= not prev_form_created
end;

What this does is this. If you close the form with the form preview
open, the form will not close. You
are forced to close the report preview first.

Comments

  • edited February 2002
    Hi Sanford,

    I don't think you found a bug in RB, and your fix isn't a fix but a
    workaround.
    Where exactly was the exception raised, was it in RB source?
    I am able to close my application in preview mode without any error.

    regards,
    Chris Ueberall;

  • edited February 2002
    In RB 6.03 at runtime, I'm able to preview a report (non modally) and then
    close the form while the previewer is still showing. No AV's. You should be
    able to close the form and have RB gracefully exit. Are you using RB 6.03?
    There must be some other code you are executing that is causing the AV to
    occur.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited February 2002
    Found the problem. An ASTA component needed to be closed!

    procedure TDataModule2.FormDestroy(Sender: TObject);
    begin
    AstaClientDataSet1.Active:= false;
    ADOConnection1.Connected:= false
    end;



  • edited February 2002
    I thought I fixed it, but after trying again, the same bug came back.

  • edited March 2002
    You are creating the datamodule in the formcreate, but what about freeing
    it? We'll need to know more about what is being created and destroyed in
    order to help. Are you referencing any data access component in the
    datamodule, after it has been freed?


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited March 2002
    Here is something that works fine:

    In the FormClose event:
    ppReport1.DataPipeline:= nil;

    You probably should have done this in the ppReport close event.


This discussion has been closed.