Creating subreport from code

Bruno de ChasseyBruno de Chassey Versailles, France
edited 9:29PM in FastReport VCL 5
I'd like to build a report entirely by code.
So far, the subreport's creation resists... and I cannot find any sample code.

I tried this (and many other options) :
SubReport:= TfrxSubreport.Create(DataBand);
  SubReport.CreateUniqueName;
  SubReport.PrintOnParent:= true;
  SubReport.Top:= 0; // * fr1cm;
  SubReport.Height:= 2 * fr1cm;
  SubReport.Width:= 5 * fr1cm;
  SubReport.Visible:= true;
  
  SubReportPage:= TFrxReportPage.Create(SubReport);
  SubReportPage.CreateUniqueName;
  SubReportPage.SetDefaults;
  SubReport.Page:= SubReportPage;

  DataBand := TfrxMasterData.Create(SubReportPage);
  DataBand.CreateUniqueName;
  DataBand.DataSet := frxDBDataset2;
  DataBand.Height := 0.5 * fr1cm;

  Memo:= TfrxMemoView.Create(DataBand);
  Memo.CreateUniqueName;
  Memo.Height:= 0.5;
  Memo.Top:=0;
  Memo.AutoWidth:= true;
  Memo.DataSet:= frxDBDataset2;
  Memo.DataField:= 'LibStat';

There is no exeption but the data is not fulfilled in the report.

Do you have any idea of what's going wrong?

Comments

  • gpigpi
    edited 9:29PM
    Attach created report template (fr3) here
  • Bruno de ChasseyBruno de Chassey Versailles, France
    edited 9:29PM
    gpi wrote: »
    Attach created report template (fr3) here
    Hi,
    I didn't know that it was possible to save the created report.
    Thanks a lot for telling me this :-)
    This is a great way to debug it... and I discovered that one dataset hadn't been associated with the report.
    This had nothing to do with the subreport itself!

Leave a Comment