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

Setting the template name of the TppReport component at runtime

edited March 2003 in General
At runtime I am having success loading reports from reports files on disk
but am not sure as to the right way to do it.

I am using this:

rptLabels.Template.Filename := ExtractFilePath(ParamStr(0)) +
'\Reports\Labels\Avery\Avry5160_ContAddr.rtm';
rptLabels.Template.LoadFromFile;
rptLabels.DataPipeline := dplLabels;
lbldbt_Address_alt5160.DataPipeline := dplLabels;
lbldbt_Address_alt5160.DataField := 'Address';
rptLabels.Print;


The rptLabels component (tppReport) is linked up on a form to a
TppDBDataPipeline but after the "LoadFromFile()" method is called above, the
DataPipeline property of the rptLabels component is nil so I need to set it
again. Prior to the LoadFromFile call the "DataPipeline" property of the
TppDBText component above (lbldbt_Address_alt5160) has a valid DataPipeline
component and after the LoadFromFile() call, in the debugger the
"lbldbt_Address_alt5160.DataPipeline" property say's "Illegal expression in
evaluation".

If I don't call the "LoadFromFile()" method the report component uses the
report file linked at design time.

Can someone offer some assistance?

Thanks,

--
Reid Roman
Future Generation Software
http://www.fgsoft.com
reidr@fgsoft.com

Comments

  • edited March 2003
    "Reid Roman" wrote in message news:3e8513e8$1@dm500....
    the
    it
    DataPipeline
    in
    This part is not required. I am guessing that "lbldbt_Address_alt5160" is a
    TppDBText or some dataaware report component. Since "ParentDataPipeLine" is
    by default true any components of a report will automatically take the
    datapipeline assigned to the report component. Just assign the Datafield
    property. I know that this still does'nt explain the error. Also, the
    file/form into which you are loading the new template must have ll the event
    handlers.
    One more thing to look at is your query is succesfully executing or not.
    Connect a DBGrid and verify that you are getting data correctly from the
    datasource to which your report datapipeline is connected.

    Correct and I guess you have to call this if you want to make use of the
    report template.

    Vikram
  • edited March 2003
    Hello,

    I have solved this. The problem was that I have three versions of each
    template and using the designer was not refreshing the reports correctly and
    had a couple of TppDBText components that lost their handler connections
    after cut and paste.

    To give you a better overview, the project has a form that has two
    TppReports and associated TppDBPipelines and TDatasources. One set is two
    use at design time to format the canned reports and the other serves as the
    conduit to load numerous report files from disk at runtime assigning
    different datasets to the report as needed. I have as many common OnPrint()
    and OnGetText() methods to do some formatting to the participating objects.

    But at runtime when I assign the report file if I do not call the
    LoadFromFile() after setting the Template.Filename property the report will
    always only show the report that is loaded into it at design time.

    The query is fine by the way.

    Thanks,

    --
    Reid Roman
    Future Generation Software
    http://www.fgsoft.com
    reidr@fgsoft.com


This discussion has been closed.