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

Error in terminate ppPreview form

edited November 2003 in General
I have a TTimer on my main menu which will call Application.Terminate when
the application idle more than 30min. This statement frees all the active
child forms including my main menu, but I get Access Violation error if I
had run a report program (TppReport on a form) and leave the report
PreviewForm active. I have no problem if I only open the report program but
didn't preview the report. Any idea what is the problem? How to solve it?
Thanks in advance.

Comments

  • edited November 2003
    Hello,

    You may be freeing the report object before the Preview form is being
    closed. Try closing the Preview form before you free anything else and see
    if that makes a difference.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2003
    I do not free anything, I just call Application.Terminate. Isn't the report
    object should free the preview form automatically when the application is
    terminated? How should I free the Preview form and in which event?

  • edited November 2003
    Hi,

    I created a simple test application consisting of a TppReport, TTimer, and a
    Button. When the button is pressed, the timer is enabled and the report
    previews. Three seconds later the timer's OnTimer event fires and the
    Application.Terminate command is executed. This seemed to work correctly
    without an AV. Please give me the exact steps you took to get this AV or
    perhaps send a small example demonstrating the behavior in .zip format to
    support@digital-metaphors.com so I can recreate it on my machine.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2003
    I manage to solve it by changing the form freeing method:-
    Application.CreateForm(TReport1,Report1);
    Report1.WindowState := wsMaximized;
    Report1.ShowModal;
    Report1.Release; {*** I changed this line, it was:-
    FreeAndNil(Report1); ***}

    I realized that when I use the FreeAndNil method and PreviewForm is opened,
    I will get an AV, if PreviewForm is not open, no AV problem. It's my
    mistake to use the FreeAndNil method for a form. Thank you very much.

This discussion has been closed.