How do I InheritFromTemplate

edited 11:30AM in FastReport 4.0
Hi All,

I'm a little new to FastReports so please bear with me, firstly I have some base templates that are used for Portrait and Landscape reports, Based on these Templates I create the required reports for the end user. Once created I save the file to a DB Blob field (DB MySQL) using the following
procedure Tf_rptmaintenance.SpeedButton1Click(Sender: TObject);
 begin
 RptDataModuleCreate;
 OpenDialog1.Filter := 'FastReport Files (*.fr3)|*.fr3';

if OpenDialog1.Execute then
   begin
try
   with dbrptdtl do
    begin
     Edit;
     TBlobField(dbrptdtl.fieldByName('Report')).LoadFromFile(OpenDialog1.FileName);

     dmRptMod.frxRpt.LoadFromFile(OpenDialog1.FileName);
     FieldByName('Caption').AsString :=  dmRptMod.frxRpt.ReportOptions.Name;
     post;
    end;
finally
end;
end;
end;

When the required report is run I load using the below code
function RptLoadfromDB(aRpt:String; AReport: TFrxReport): boolean;
var rptQuery : TMyQuery;
    RptStream: TStream;
begin
try
   rptQuery := TMyQuery.Create(nil);
   AReport.Clear;
   with RptQuery do
    begin
     Connection := MainDataForm.appdata;
     SQL.Add('Select * from rpt_dtl where Caption = :Rpt limit 1');
     ParamByName('Rpt').AsString := ARpt;
     Execute;
    end;
  if rptquery.FieldByName('AllowDelete').AsBoolean then
    begin
     RptStream := TMemoryStream.Create;
    (rptquery.FieldByName('Report') as TBlobField).SaveToStream(RptStream);
     Rptstream.Position := 0;
     AReport.report.LoadFromStream(RptStream);
    end;
finally
    rptQuery.FreeOnRelease;
    RptStream.free;
end;
end;

All fairly straight forward except because the report has used a Template It would seem that either I need to break the link with the template or InheritFromTemplate , this I thought I could also load from the DB !

After all the above can I ask for help on loading the template using a stream or how to break the link so the required report can run

Again appreciate the forum's help

rgds

tchant >

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 11:30AM
    template report must be located in the designers template directory.

Leave a Comment