Home Subreports

Dynamically Loaded Header

edited August 2002 in Subreports
I have a dynamically loaded header TMyHeader derived from TppSubReport, just
like in the demo application '5. Dynamic Subreport Loading'. The only
difference is that on this header I use DADE connected to a TppDBText to
retrieve the text from a table with just one record in it.

When I add this header to a report and try to preview it, I get the error :
'Data source name not found and no default driver specified'.

Anyone an idea what am I missing ?

Thanks,

Samuel

Comments

  • edited August 2002
    It seems to work OK if I put in the StartOfMainReport :

    TdaQueryDataView(Report.DataPipeline.DataView).Active := False;
    TdaQueryDataView(Report.DataPipeline.DataView).Active := True;

    BUT, every time I open the report in the designer and preview it, the
    DataPipeline of the header is added to the main report, so after 5 edits I
    have 6 DataPipelines on the report, 5 of which are all duplicates of the one
    on the header sub report.

    Any suggestions of how to get rid of them afterwards, maybe in the
    EndOfMainReport ?

    Thanks,

    Samuel.

  • edited August 2002
    This is the merging behavior of the dataviews. They should merge the
    dataviews into the main report when you load a template.

    What you can do is delete the dataviews from the templates that you are
    going to load as subreports. Leverage the fact that hte controls in the
    subreport will connect to the dataview that the subreport is assigned to
    when you load the template to the main report.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited August 2002
    But then I would have to define that dataset in each report I will load the
    header template into. That beats half of the purpose of having a reusable
    header. Surely, there must be a better way.

    Samuel.

  • edited August 2002
    Probably the best way to handle this problem is with a workaround: Add the
    dataview needed by the header subreport to the main report. Delete the
    dataview from the header template. After loading the template, assign the
    data pipeline from the 'header' dataview to the subreport. If
    ParentDataPipeline is set to True on all of the DBText components, that's
    all you'll need to do. Otherwise, loop through the subreport and reattach
    the DBText components to the data pipeline.

    The data module is slightly different from the code module or report module
    objects (which are nested one-to-one based on the subreport structure.) The
    data module was designed to function as a 'global' container for all
    dataviews. This seems to make the most sense, given the linked dataviews
    that many developers need. The side effect in this instance is that
    dataviews 'collect' in the data module as you load templates over and
    over...

    Cheers,

    Tom Ollar
    Digital Metaphors Corporation
This discussion has been closed.