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

Report templates

edited May 2005 in General
I have a report that has already been designed. The details of the report
are stored in the TppReport component on the form. Since it is a full report
there are already components on the report, e.g. a TppImage. This report is
fine and is working. However, we have some clients that want to move the
format around a little bit. So I thought I would use the report template
stuff in ReportBuilder. But I can't get it to work as I want it to.

I have saved the report to an rtm file. I then edited the rtm to give a
different layout of the report. So now I have the TppReport on the form
which contains the full standard report. In my code I check for the
existence of the template file. If it exists I then attempt to load it. Just
before I load the template, the TppImage shows as ([csInheritable]) showing
that it has been created from the TppReport already on the form. I then load
the template into this TppReport. Now the TppImage shows as nil. This means
that I have lost all references to the objects that were in my report. How
do I refer to the objects now? What happened to them? Can ReportBuilder
handle what I am trying to do?

Regards

Jeff

Comments

  • edited May 2005
    Hi Jeff,

    There should not be anything complicated about what you are trying to do.
    How and where are you loading the template into the report object? When
    loading templates, be sure to use the following method....

    ppReport1.Template.FileName := 'c:\myReport.rtm';
    ppReport1.Template.LoadFromFile;
    ppReport1.Print;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2005
    I thought it was supposed to be simple!

    I have tried loading the template at different points. The one that i would
    have thought should have worked was in the create of the datamodule on which
    the original TppReport is based.

  • edited May 2005
    Hi Jeff,

    I'm sorry, I'm unclear about your response. Are you using the method I
    described below to load your templates? Are you doing anything else in the
    process. In my testing with virtually identical reports, everything seemed
    to work correctly.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2005
    Yes I am doing as you suggested below. What I meant was that I have tried
    placing the code in different events and it doesn't matter where I palce the
    code, it doesn't work.

    So let me try to get something clarified from you If I have a report
    already defined, then when the datamodule that report is on is opened it
    will create instances of the objects that are on the report (labels, images,
    etc). When I load a template that has the same components (just placed in a
    different positions), the origina lreport objects should now point to the
    new report objects? They should not be getting set to nil. Correct?





  • edited May 2005
    Hi Jeff,

    Once you load a new template into a report object that already has a
    template loaded, the original report and all its components are destroyed.
    Then, when the new template is created, all the objects are recreated as
    well. If you are referencing any of these objects perhaps in an event that
    is not defined in the new template or by different names, you will receive
    an error.

    What exactly are you trying to do? When you load the new template, what
    needs to happen to certain report components at run time?

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2005
    All I want to do is be abe to have a standard layout for certain reports.
    These components for these reports are on the form included with the
    executable.

    Some clients want to be able to move the components around to get their own
    layout (just being fussy). I want to be able to use the template to simply
    move the position of these components. That simple.

    I am not seeing the components beng created when I load the template in the
    CReate method of the datamodule. I would have thought at this stage this was
    a standard event and nothing to do with the reports events.



  • edited May 2005
    Got it sorted out. Not even going to embarass myself and try to explain what
    I was doing wrong.

    Thanks for your patience and assistance.

This discussion has been closed.