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

Subreport Data Source

edited January 2003 in Subreports
This is a multi-part message in MIME format.

Comments

  • edited January 2003
    This is a multi-part message in MIME format.
  • edited January 2003
    Yes, it's the Dataview. This works great when I manually load the subreport
    into the main report, save and preview.

    When I use the demo "Dynamic Subreport Loading" and use the specialized
    component to dynamically load the subreport - the main report finds the
    subreport but the subreport can not find it's datapipeline.

    Any ideas? Do I need to modify the demo somehow to allow datapipelines
    instead of static text?




    Original Post Follows - - - - -

  • edited January 2003
    You'll have to reconnect the pipeline to the subreport after the subreport
    is loaded. I'll have to try this with the demo to see if there are any
    other gotchas. Might have to come up with unique dataview names (see the
    Dataview.Description property) before merging the dataview so that the
    subreport can be connected to its dataview without worrying about a name
    change on the pipeline component.

    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited January 2003
    Thanks - This would be of great help!

    Would I do this using Rap? Which event would be most approriate?


  • edited January 2003
    In RAP, if you were to try to do anything like this it would have to be the
    global OnCreate event, as this fires before all other events in RAP. Even
    then, it may be too late, because the printing process has begun. A better
    point of entry is the public Report.Template.OnLoadEnd event in Delphi code.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited January 2003
    I'm stumped. I can't seem to reassign the pipeline to the subreport after
    it's loaded.

    Any chance of getting the updated "Dynamic Loading Subreport" demo from you?

    TIA


  • edited January 2003
    I have two research projects in my queue for today and then I will try to
    create a demo before continuing on with new development for the day. Thanks
    for your patience.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited January 2003
    If you put a breakpoint in the TmyDynamicLoadingSubReport.LoadTitleSubreport
    after it loads from file, you can see that it has the datapipeline object
    instantiated, however, it appears to be too late to merge the dataview
    created from this subreport into the datamodule, because the report is
    already running. It gets merged, but the SQL is not generated and the
    pipeline is not opened. In order to do this you have the option of accessing
    the dataview like this to get it to work in the LoadTitleSubreport routine.
    I did create a Orders dataview in the template which had a single record in
    it showing a sum calc field for all orders and displayed it in a DBText in
    the title band. IT seems to work ok. Try it out and let me know if you get
    it working or not.

    uses
    daDBBDE;

    You'll have to use the DADE plugin in this unit as you are using in your EU
    project. This is the way to access the public SQLChaged method of the query
    dataview class that is being used. It is protected in the ancestor so you
    have to use the descedent plugin class which introduces it as public.
    ...
    ..
    .
    Report.Template.LoadFromFile;

    if (Report.DataPipeline <> nil) and (Report.Datapipeline.DataView is
    TdaBDEQueryDataView) then
    begin
    TdaBDEQueryDataView(Report.Datapipeline.DataView).SQLChanged;
    Report.Datapipeline.Open;
    end;


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited January 2003
    Closer I think...

    I'm using DOA so I included daDOA into the unit and tried this code in the
    LoadHeaderSubreport. There isn't a "SQLChanged" method exposed for DOA so I
    tried various other methods with no luck.

    With this code I get an error saying "Session Undefined".

    The "Extended Header" subreport I'm using previews fine when run stand
    alone.


    procedure TmyDynamicLoadingSubReport.LoadHeaderSubreport;
    var
    lIniFile: TIniFile;
    lbLoadFromFile: Boolean;
    begin

    Report.Template.DatabaseSettings.DataPipeline :=
    Band.Report.MainReport.Template.DataBaseSettings.DataPipeline;
    Report.Template.DatabaseSettings.NameField :=
    Band.Report.MainReport.Template.DataBaseSettings.NameField;
    Report.Template.DatabaseSettings.TemplateField :=
    Band.Report.MainReport.Template.DataBaseSettings.TemplateField;
    Report.Template.DatabaseSettings.Name := 'Extended Header';
    Report.PrinterSetup.DocumentName :=
    Band.Report.MainReport.PrinterSetup.DocumentName;
    Report.Template.LoadFromDatabase;

    if (Report.DataPipeline <> nil) and (Report.Datapipeline.DataView is
    TdaDOAQueryDataView) then
    begin
    TdaDOAQueryDataView(Report.Datapipeline.DataView).OutOfSync;
    Report.Datapipeline.Open;
    end;

    end; { procedure, LoadHeaderSubreport }





  • edited January 2003
    Instead of protected, make SQLChanged a public method override in your copy
    of daDOA.pas.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited January 2003
    Yes! Almost....

    The subreport now dynamically loads IF the subreport is in the same folder
    in the database. I can't seem to dynamically find a different subreports
    folder.

    For example

    Main report: Master\Inventory\Parts by ID
    Subreport: Templates\Extended Header



    I would think setting this in the Delphi code would have done it but no.

    Report.Template.DatabaseSettings.Name := 'Templates\Extended Header';

    What am I missing to make it find another folder? I'm SO CLOSE!

    RB 7.01 Enterprise - Reports are stored in an Oracle database with
    "standard" table names and structures.



This discussion has been closed.