Report Component is Nil

edited August 2001 in General
Hi,

I am having an intermittent problem that occurs without a solid reason. I am
using version 6.01, and have a report form with a TReport on it. When the
report fires either the DBText.GetText or the Memo.OnPrint events, the
Report component is nil. My question is, if the report component is nil or
not assigned, then how is the event getting fired? On my clients machine who
has had a problem with this particular report crashing intermittently, I
inserted the code:

if ReportForm.Report = nil then
ShowMessage('Report is nil, call John');

into the event handlers and they had the message pop up.

How can this be?

John Jensen

Comments

  • edited August 2001
    Exactly how are you referencing the report? It looks like you have a TForm
    descendent which has a report on it and a report property? What if you
    reference the report by name? The form should own the report and you should
    be able to get a reference to that object since it sits on the form. What
    version of Delphi are you using?


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited August 2001
    I have a reporting DLL which contains a form for each report setup. The DLL
    also contains one form with a single TReport on it and I have named it
    Report. When each setup form's print button is pressed, dynamic queries are
    build, the form with the TReport on it is instantiated, the correct report
    template is loaded and the ReportForm.Report.Print method is called.

    Like I said, this report will run fine 9 out of 10 times, and then this
    error will occur where the report component is nil inside the events. It is
    really bizarre. One other thing to note about this particular report is, it
    is really a sequence of 4 different report templates that are loaded in
    sequence, and the printer tray may be swapped for each report. The sequence
    is like, Transmittal, Certificate, Backing Sheet, Log. This series may play
    over and over many times before the job is done, but at no time do I free
    the report or the report form objects.

    My client says that after I trapped the errors and they click through them,
    the reports print to completion without any data missing or other errors.

    I am using Delphi 5 with RB 6.01.

    Thanks for any ideas.

    John



  • edited August 2001
    After a report template is loaded, are you reassigning the event handlers?
    Perhaps the report's events are getting linked to event handlers in a
    different form unit where the report component is nil?


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.