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

swtiching templates using RAP

edited September 2005 in General
Hello,

I would like to be able to switch between different templates based on the
values of certain fields in a pipeline. For example, if field IvoiceNumber
is not null, then I want to load the invoice template, when it is null, then
I want to print just an order.

Yes, I know about loading templates from a database or file, BUT the
conditions under which I will have to switch different templates can be
almost completely random for one client or another. I thought that I could
use RAP to write a piece of code without having to recompile the entire
program.

Therefore, is it possible to load a certain "loader" template, which has a
piece of rap code in it, which evaluates the database values and then loads
the appropriate template (via report.tempalte.loadfromdatabase for example)?

Remember, I do not want to recompile the EXE, and the possible conditions
under which I have to load one template or another are not known in advance.

Cheers,
Dimitar

Comments

  • edited September 2005

    The report engine initializes all reports/subreports prior to report
    generation. Therefore you do not want to load any templates while the report
    is generating.

    1. A standard solution to this requirement is to create a report that
    contains subreports. Each subreport representing a template. Then toggle the
    subreport Visible property based upon the data values.

    2. You could use the new Report.OnInitializeParameters event introduced by
    RB 9 to write some RAP code to do configure the report or load templates. I
    recommend approaching this incrementally. First build a prototype using
    Delphi code and then once you get it working convert to RAP code. You can
    create one or more RAP pass-thru functions as needed. See the Extending RAP
    article in the RAP thread of the Tech Tips newsgroup for more info.

    3. Another alternative is to use the Report.Template.OnLoadEnd event from
    Delphi. So this would be Delphi code that fires when you load a template.
    Then you could analyze the data and take action.


    --
    Nard Moseley
    Digital Metaphors Corporation
    http://www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.