Home General

Closing a report closes the calling form...

edited August 2017 in General
Hi Team,
Given the following code..
{code}
procedure TAppointmentsForm.btnPrintCurrentListClick(Sender: TObject);
begin
//
with ReportsFrm.ReportsForm do
begin
ppRE1.LoadReport('Appointments', 2);
ppR1.ShowAutoSearchDialog := False;
ppR1.Print;
ppR1.FreeModules
end;
//
end;
{code}

When I close the report it closes the form it was called from if the form is called as follows. Not desirable. :-(
{code}

procedure TMainForm.AppointmentsTableClick(Sender: TObject);
var
AppointmentsForm: TAppointmentsForm;
begin
//
screen.cursor := crHourglass;
AppointmentsForm := TAppointmentsForm.Create(Application);
screen.cursor := crDefault;
//
AppointmentsForm.ShowModal; <<<<<<<<
//
end;
{code}

If I change AppointmentsForm.ShowModal; to AppointmentsForm.Show;, the Appointments form doesn't close.

I prefer ShowModal as it prevents the user getting 'lost'.

Thoughts/suggestions appreciated.

Regards & TIA,
Ian

Comments

  • edited August 2017
    Hi Ian,

    Closing a preview window should not automatically close the parent/owner
    form. Are you certain there is no event code closing the form
    automatically?

    If not, please create a simple example that demonstrates this behavior
    and send it to support@digital-metaphors.com in .zip format.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2017
    Nico Cizik (Digital Metaphors) wrote:

    IB - Not by me.

    IB - Will do.

    Regards,
    Ian
This discussion has been closed.