Creating subreport from code

Bruno de ChasseyBruno de Chassey Versailles, France
edited 12:43PM 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 12:43PM
    Attach created report template (fr3) here
  • Bruno de ChasseyBruno de Chassey Versailles, France
    edited 12:43PM
    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

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.