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

Configuring default template

edited June 2002 in General
Alexander,

you mentioned previously (thread 'configuring template for end user report')

<<
You must specify the file to load from. ie.

Report.Template.FileName := 'mytemplate.rtm';
Report.Template.LoadFromFile;

I am assuming this should be in the Create Report event of the Report
Explorer:

procedure TDataModuleReportExplorer.ReportDesignerCreateReport(
Sender: TObject; const aDataName: String; var aReport: TObject);
begin
Report.Template.FileName := myFileName.rtm';
Report.Template.LoadFromFile;
end;

However, this does not load the template . . .

Any other ideas?

Thanks,

Lauchlan Mackinnon.

Comments

  • edited June 2002
    The CreateReport event is set to fire when the user selects the new report
    option from the designer file menu. To load a template when the designer
    first open use the Report.Template.OnNew event.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited June 2002
    > The CreateReport event is set to fire when the user selects the new report

    Thanks Alexander.

    Lauchlan Mackinnon.
  • edited June 2002
    > The CreateReport event is set to fire when the user selects the new report

    Actually, that;s what I want. This event does not seem to fire though (I
    have a breakpoint there that it doesn't reach).
  • edited June 2002
    How are you assigning the event? The CreateReport event is set to fire when
    the new report wizard finishes creating the report. The OnNew event will
    fire both, when the user first opens the designer and when they select the
    new report option from the designer menu. The CreateReport event you can
    assign at design time on the designer component. The OnNew event you can
    assign in the FormCreate for your application. If the event aren't firing
    just make sure that they are not being reassigned anywhere else.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited June 2002
    > How are you assigning the event? The CreateReport event is set to fire
    when

    Alexander,

    I now have

    procedure TDataModuleReportExplorer.DataModuleCreate(Sender: TObject);
    begin
    Report.Template.OnNew := NewReportHandler;
    Report.Template.OnLoadEnd := LoadEndEvent;
    ReportDesigner.Viewer.ZoomSetting := zsPageWidth; // or whatever setting

    end;

    procedure TDataModuleReportExplorer.NewReportHandler(Sender:TObject);
    begin

    Report.Template.FileName := 'ReportDefault.rtm';
    Report.Template.LoadFromFile;
    Subreport1.Report.Template.FileName := 'myHeader.rtm';
    Subreport1.Report.Template.LoadFromFile;

    end;

    It loads the report in the design tab and I see the subreport band, ir it
    seems in the design tab to load exactly as I want. When I go to preview
    however, it tries to load a datasource where the driver etc aren't specified
    (ie, one I didn't create) and crashes out.

    Nonetheless, it is progress! Everything works as desired until I try to use
    preview tab.

    Why would it invent a fictitious datasource?

    I have two templates. One is loaded into the report, and has a title,
    header, detail and footer band. The title band has a subreport, into which I
    load the second template which has a title and detail band. The title band
    has only 1 image and 1 caption (no data). I set the subreport up with a
    pipeline to try to appease the above behaviour, but it makes no difference.

    What do I need to do next?

    Thanks,

    Lauchlan Mackinnon.
  • edited June 2002
    Apparently the templates which you are loading are expecting to be
    reconnected to some specific data source. That data source should reside in
    the data module with the report object into which the templates are being
    loaded.Basically be sure to reconnect the report and the subreport to valid
    pipelines with the same field that the report expects.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited June 2002

    "Alexander Kramnik (Digital Metaphors)" wrote
  • edited June 2002
    You could still have active dataviews in the report even if they are not
    being used by anything in the report which could cause this problem.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

This discussion has been closed.