Home General

Access Violation on Report Free

edited September 2001 in General
I have a form where I'm using a TppViewer component. All of my reports
are contained in TForms. On the main form (where the TppViewer is), the
user selects reports from the menu bar.

The problem I'm having is when the application is closed while a report
is busy, or the user selects a new report from the menu bar while the
current report is busy. When this happens, the application crashes
(Access violation).

When a menu item is selected, or the application closes, I execute the
following code:

{currentReport is a public var, holding a reference to the TForm with
the TppReport}

currentReport.ppReport1.Cancel;
currentReport.ppReport1.Reset;
FreeAndNil(currentReport); {crashes here}

I've tried this with/without the ppReport1.Reset, but same results
occur. Can anyone help? (using RB 5.5, but tried 6.01, too.)

Thanks.

Comments

  • edited September 2001
    Cancel should stop the report from generating. Reset doesn't need to be
    called. So, the viewer is still running when you free the report? You'll
    want to stop the viewer before you free the report. You can call
    Viewer.Cancel and and disconnect the report from the viewer.

    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited September 2001
    I'm still getting access violations here...I've updated the code to call
    ppViewer1.Cancel, too:

    ppViewer1.Cancel;
    currentReport.ppReport1.Cancel;
    FreeAndNil(currentReport);

    Any ideas?

    Thanks.
This discussion has been closed.