InheritFromTemplate, Datasets

edited 8:13PM in FastReport 4.0
Hello

I have a question. I'm not sure what is the problem. I'm using Delphi 5 and FastReport 4.7.5 Professional. I've created a simple example of my problem:

On a form I have two frxReport components frxReport1 and frxReport2 all properties with defaults. frxReport1 contain only PageHeader with one Memo. frxReport2 contain MasterData linked to IBQuery1:TfrxIBQuery, and IBDatabase: TfrxIBDatabase. Query contain simple select statement, and on MasterData I drop one field.

I'd like to use inheritance (target report is Report2, Report1 is a parent report), but both Reports have StoreInDFM set to True. So i write the folowing code to achive this:

procedure TForm1.frxReport2LoadTemplate(Report: TfrxReport;
const TemplateName: String);
var theMS : TMemoryStream;
begin
If TemplateName = 'templ' then
Begin
theMS := TMemoryStream.Create;
try
frxReport1.SaveToStream(theMS);
theMS.Position := 0;
Report.LoadFromStream(theMS);
finally
theMS.Free;
end;
End;
end;

(It works fine without dataset in report2). But when I put frxIBQuery in report2 and do the folowing:

frxReport2.InheritFromTemplate('templ'); // when I comment this line it works fine
frxReport2.ShowReport;

i get exception:

Dataset "IBQuery1" not exists

What is going on ?

I've observed one interesting thing, before I call InheritFromTemplate in debuger:

frxReport2.datasets[0] : ($DE5680, 0, $F1512C, 'IBXQuery1')

and after call InheritFromTemplate:

frxReport2.datasets[0] : ($DE5680, 2, nil, 'IBXQuery1')

Best regards
b

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 8:13PM
    IIRC inheriting one report from another requires the parentreport to be stored in a template dir as an fr3 file, you can't work with them stored in .dfm files.
  • edited March 2009
    gordk wrote: »
    IIRC inheriting one report from another requires the parentreport to be stored in a template dir as an fr3 file, you can't work with them stored in .dfm files.

    ? Hmmm ?

    I stored the parent report in fr3 file (I've removed OnLoadTemplate event handler from my source) and there is the same effect.

    I thougt (I've read that in Yours docs) that event OnLoadTemplate is designed to load template from any source (for example templates sotred in DB).

    By the way, the method I've presented works fine if there is no frIBQuery component in frxReport1.

    // Edit

    Of course I set StoreInDFM to False in parent report.
  • gordkgordk St.Catherines On. Canada.
    edited 8:13PM
    By the way, the method I've presented works fine if there is no frIBQuery component in frxReport1

    is this a typo
    frIBQuery component

    and you meant
    frxIBQuery component
  • edited 8:13PM
    I mean: TfrxIBXQuery (FR DB components)

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.