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

How to capture a faulty template

edited July 2006 in End User
Hi,

In a classic Report Explorer application, what is the best place to capture
the fact if a template is faulty.
For example if the report template is old and the database has changed.
I want to be able to capture the fact that the template is faulty and notify
the user, without opening the report.

Thanks

Shahine

Comments

  • edited July 2006

    Try using the Report.Template.OnLoadEnd event. You could inspect the
    template and try to fix anything that you can detect is wrong or raise an
    exception.



    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited July 2006
    Hi Nard Moseley,

    Thanks for getting back to me.
    OK, I have an event "TRepForm.myTemplateOnLoadEndEvent(Sender: TObject);"
    declared.
    But how can I see if the template actually loaded or not?

    Before I started using the report explorer, I was loading the reports
    manually and had something like:

    Try
    ppReport1.Template.LoadFromDatabase;
    except
    MessageDlg('Report Template did not load', mtError, [mbOK], 0);
    end;

    as a simple way of knowing template did not load, therefore something is
    wrong with it.
    I simply want to know if the template loaded ok or not? and if it did not
    then not to go any further.

    Thanks

    Shahine Ghanbarzadeh




  • edited July 2006

    The report explorer should be doing what you describe automatically. It
    should not display the designer if the template does not load successfully.
    I researched this further and the TppReportExplorer.LoadReport method has a
    try..except that needs to re-raise the exception. We will fix this for the
    next maintenance release, which will be RB 10.04. For your existing code,
    open ppRptExp.pas, locate the TppReportExplorer.LoadReport and add a raise
    statement at the end of the try..except - so that it looks like the example
    below. Copy ppRptExp.pas to RBuilder\Lib and delete the corresponding .dcu,
    the rebuild your Delphi project to generate a new .dcu.

    try

    {load report}
    except
    {receove from exception}
    raise;

    end;




    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited July 2006
    Thank You.

    Did the trick. Exactly what I was looking for.

    Shahine






This discussion has been closed.