Close
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.
(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.
This discussion has been closed.
Comments
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;
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
http://www.digital-metaphors.com
info@digital-metaphors.com
procedure TDataModule2.FormDestroy(Sender: TObject);
begin
AstaClientDataSet1.Active:= false;
ADOConnection1.Connected:= false
end;
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
http://www.digital-metaphors.com
info@digital-metaphors.com
In the FormClose event:
ppReport1.DataPipeline:= nil;
You probably should have done this in the ppReport close event.