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

SubReport problem in Code

edited September 2001 in General
Hello,

I like create subreport in code but it doesn't work.
How can we solve it?

My source:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ppReport, StdCtrls;

type
TForm1 = class(TForm)
published
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
FReport: TppReport;
end;

var
Form1: TForm1;

implementation

uses ppTypes, ppCtrls, ppSubRpt;

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var L: TppLabel;
SubReport: TppSubReport;
ChildReport: TppChildReport;
begin
FReport:= TppReport.Create(nil);
FReport.CreateDefaultBands;
FReport.DetailBand.PrintHeight:= phDynamic;
FReport.DeviceType:= 'Screen';

SubReport:= TppSubReport.Create(FReport);
SubReport.Band:= FReport.DetailBand;
SubReport.CreateReport(FReport);
SubReport.ExpandAll:= False;
SubReport.NewPrintJob:= False;
SubReport.TraverseAllData:= False;

ChildReport:= TppChildReport.Create(SubReport.Report);
ChildReport.CreateDefaultBands;

L:= TppLabel.Create(SubReport);
L.Caption:= 'Label1';
L.UserName:= 'Label1';
L.Band:= ChildReport.DetailBand;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
if Assigned(FReport) then
FReport.Destroy;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
FReport.Print;
end;

end.

Comments

This discussion has been closed.