Board index » delphi » QR2 Exit stage right

QR2 Exit stage right

Whenever I run a QR2 preview or a child form using

OnButtonClick
try
 Create and show
Finally
 free
end

It also closes the form with the button on from which it was called.
Has anyone else experienced this?

Pat Bell

Using Virtual Access
http://www.vamail.com

 

Re:QR2 Exit stage right


I suspect that you're not being specific enough. Here's a code snippet
that works. Note that the Create is outside the try..finally loop and
that I've been specific about what to free.

procedure TPrintDlg.PrintDate(aDate: TDateTime);
var
  Itin: TItinForm;
begin
  Itin := TItinForm.Create(Self);
  try
    Itin.RDate := aDate;
    Itin.ItinRep.Preview;
  finally
    Itin.Free;
  end;
end;

If there are more commands in the try block I us a construct like this,
but still specify Itin.Free;

procedure TPrintDlg.PrintDate(aDate: TDateTime);
var
  Itin: TItinForm;
begin
  Itin := TItinForm.Create(Self);
  try with Itin do
    begin
    RDate := aDate;
    ItinRep.Preview;
    end;
  finally
    Itin.Free;
  end;
end;

Hope something here helps.

-Dennis

Re:QR2 Exit stage right


Dennis/

I have taken your advice and moved the create out of the try..finally
block. I had previously been advised to put it in the try block (for
forms in any case).

I still have the problem though, the following code shows what I do -
Load the fmCHPrintout form from which a button is pressed which loads
the quickreport. When this report finishes control does not pass back
to fmCHPrintOut but to its 'parent' from whence it was created:

 fmPrintOut:=TfmPrintOut.Create (Application);
 Try
  fmPrintOut.showmodal; // show selection including Print Report
 finally
  fmPrintOut.Free;
 end; . . .
// Print Report
 fmQRContactInstrctn:=TfmQRContactInstrctn.Create (Application);
 Try
  fmQRContactInstrctn.QuickRep1.Preview
 finally
  fmQRContactInstrctn.Free;  // frees fmCHPrintOut too (or at least    
          // makes it invisible and pass control back to its parent.
 end;

Is this not specific enough? All my forms have Visible=False.

Pat Bell

Using Virtual Access
http://www.vamail.com

Re:QR2 Exit stage right


Pat,

You are being specific enough, and I don't see where your problem lies.

I am going to  forward a copy of this to your e-mail address with a
little sample program attached. It does what I understand you are trying
to do in the simplest form using one of the DBDEMO data tables. It does
not exhibit the problem you describe, at least not on my system.

See if it works right on your system, then you can compare what you are
doing to it to try to locate the problem. Let me know if you have any
more problems.

-Dennis

Re:QR2 Exit stage right


Thanks, I'll await the sample. It seems to be just on QR reports
(preview or print) that it happens.

Pat Bell

Using Virtual Access
http://www.vamail.com

Other Threads