Header & Footer bands don't appear

edited 2:38AM in FastReport 4.0
Hi there,

I???m using Delphi XE5 & Fast Reports 4 VCL. I???m developing a program which creates a FastReport report runtime. My problem is that the Header & Footer bands don???t appear. I???m sending 3 versions of source code (1st w/o Header & Footer, 2nd & 3rd w/ Header & Footer). On Form1 there are 3 buttons (Button1, Button2, Button3), on DataModule there are an FDConnection and an FDQueryFR (TFDQuery).

What can be the problem? Any help would be appreciated!

Thanks,
Rossi


The difference is between the versions is that the order of the band creation are different:

Version #1: MasterData (no Header & Footer)
Version #2: Header ??? MasterData ??? Footer
Version #3: MasterData ??? Header ??? Footer


RESULTS:


VERSION #1: when I click Button1, the report appears normally (Name & Birth fields).

VERSION #2: when I click Button2, an error message appears: ???The following error(s) have occured: Unconnected header/footer Header1???. And, after clicking OK an empty report (gray background) appears.

VERSION #3: when I click Button3, there is no error message. The Header and Footer and sql result don???t appear, but only a blank page appears.


Code VERSION #1:

procedure TForm1.Button1Click(Sender: TObject);

var
Report: TfrxReport;
Page: TfrxReportPage;
MasterData: TfrxMasterData;
Memo: TfrxMemoView;
Memo2: TfrxMemoView;

begin

// set query (FireDAC)

DataModule.FDQueryFR.Active := False;
DataModule.FDQueryFR.SQL.Clear;
DataModule.FDQueryFR.SQL.Add('Select Name, Birth From SQLData Limit 20');
DataModule.FDQueryFR.Active := True;

// create Report object

Report := TfrxReport.Create(Self);
Report.Name := 'frxReport';

// create Page object

Page := TfrxReportPage.Create(Self);
Page.Parent := Report;
Page.Name := 'frxReportPage';

// create a MasterData band

MasterData := TfrxMasterData.Create(Self);
MasterData.Parent := Page;
MasterData.Name := 'MasterData1';
MasterData.DataSet := frxDBDataset1; // exists on Form1, DataSet property = DataModule.FDQueryFR
MasterData.Height := fr01cm * 6;

// create Memo objects to show data from database

Memo := TfrxMemoView.Create(Self);
Memo.Parent := MasterData;
Memo.Name := 'frxMasterData_Name';
Memo.SetBounds(fr01cm * 0, fr01cm * 0, fr01cm * 200, fr01cm * 5);
Memo.DataSet := frxDBDataset1; // exists on Form1, DataSet property = DataModule.FDQueryFR
Memo.DataField := 'Name';

Memo2 := TfrxMemoView.Create(Self);
Memo2.Parent := MasterData;
Memo2.Name := 'frxMasterData_Birth';
Memo2.SetBounds(fr01cm * 100, fr01cm * 0, fr01cm * 100, fr01cm * 5);
Memo2.DataSet := frxDBDataset1; // exists on Form1, DataSet property = DataModule.FDQueryFR
Memo2.DataField := 'Birth';

// prepare and show report

Report.PrepareReport;
Report.ShowPreparedReport;

// free report

Report.Free;

Exit;

end;


Code VERSION #2:

procedure TForm1.Button2Click(Sender: TObject);

var
Report: TfrxReport;
Page: TfrxReportPage;
MasterData: TfrxMasterData;
Memo: TfrxMemoView;
Memo2: TfrxMemoView;
Header: TfrxHeader;
Footer: TfrxHeader;

begin

// set query (FireDAC)

DataModule.FDQueryFR.Active := False;
DataModule.FDQueryFR.SQL.Clear;
DataModule.FDQueryFR.SQL.Add('Select Name, Birth From SQLData Limit 20');
DataModule.FDQueryFR.Active := True;

// create Report object

Report := TfrxReport.Create(Self);
Report.Name := 'frxReport';

// create Page object

Page := TfrxReportPage.Create(Self);
Page.Parent := Report;
Page.Name := 'frxReportPage';

// create Header band

Header := TfrxHeader.Create(Self);
Header.Parent := Page;
Header.Name := 'Header1';
Header.Height := fr01cm * 5;
Header.Visible := True;
Header.Stretched := True;

// create Memo in Header band

with TfrxMemoView.Create(Self) do
begin
Parent := Header;
Name := 'frxHeader_Memo';
SetBounds(fr01cm * 0, fr01cm * 0, fr01cm * 200, fr01cm * 5);
Memo.Text := 'Header';
end;

// create a MasterData band

MasterData := TfrxMasterData.Create(Self);
MasterData.Parent := Page;
MasterData.Name := 'MasterData1';
MasterData.DataSet := frxDBDataset1; // exists on Form1, DataSet property = DataModule.FDQueryFR
MasterData.Height := fr01cm * 6;

// create Memo objects to show data from database

Memo := TfrxMemoView.Create(Self);
Memo.Parent := MasterData;
Memo.Name := 'frxMasterData_Name';
Memo.SetBounds(fr01cm * 0, fr01cm * 0, fr01cm * 200, fr01cm * 5);
Memo.DataSet := frxDBDataset1; // exists on Form1, DataSet property = DataModule.FDQueryFR
Memo.DataField := 'Name';

Memo2 := TfrxMemoView.Create(Self);
Memo2.Parent := MasterData;
Memo2.Name := 'frxMasterData_Birth';
Memo2.SetBounds(fr01cm * 100, fr01cm * 0, fr01cm * 100, fr01cm * 5);
Memo2.DataSet := frxDBDataset1; // exists on Form1, DataSet property = DataModule.FDQueryFR
Memo2.DataField := 'Birth';

// create Footer band

Footer := TfrxHeader.Create(Self);
Footer.Parent := Page;
Footer.Name := 'Footer1';
Footer.Height := fr01cm * 5;
Footer.Visible := True;
Footer.Stretched := True;

// create Memo in Footer band

with TfrxMemoView.Create(Self) do
begin
Parent := Footer;
Name := 'frxFooter_Memo';
SetBounds(fr01cm * 0, fr01cm * 0, fr01cm * 200, fr01cm * 5);
Memo.Text := 'Footer';
end;

// prepare and show report

Report.PrepareReport;
Report.ShowPreparedReport;

// free report

Report.Free;

Exit;

end;


Code VERSION #3:

procedure TForm1.Button3Click(Sender: TObject);

var
Report: TfrxReport;
Page: TfrxReportPage;
MasterData: TfrxMasterData;
Memo: TfrxMemoView;
Memo2: TfrxMemoView;
Header: TfrxHeader;
Footer: TfrxHeader;

begin

// set query (FireDAC)

DataModule.FDQueryFR.Active := False;
DataModule.FDQueryFR.SQL.Clear;
DataModule.FDQueryFR.SQL.Add('Select Name, Birth From SQLData Limit 20');
DataModule.FDQueryFR.Active := True;

// create Report object

Report := TfrxReport.Create(Self);
Report.Name := 'frxReport';

// create Page object

Page := TfrxReportPage.Create(Self);
Page.Parent := Report;
Page.Name := 'frxReportPage';

// create a MasterData band

MasterData := TfrxMasterData.Create(Self);
MasterData.Parent := Page;
MasterData.Name := 'MasterData1';
MasterData.DataSet := frxDBDataset1; // exists on Form1, DataSet property = DataModule.FDQueryFR
MasterData.Height := fr01cm * 6;

// create Memo objects to show data from database

Memo := TfrxMemoView.Create(Self);
Memo.Parent := MasterData;
Memo.Name := 'frxMasterData_Name';
Memo.SetBounds(fr01cm * 0, fr01cm * 0, fr01cm * 200, fr01cm * 5);
Memo.DataSet := frxDBDataset1; // exists on Form1, DataSet property = DataModule.FDQueryFR
Memo.DataField := 'Name';

Memo2 := TfrxMemoView.Create(Self);
Memo2.Parent := MasterData;
Memo2.Name := 'frxMasterData_Birth';
Memo2.SetBounds(fr01cm * 100, fr01cm * 0, fr01cm * 100, fr01cm * 5);
Memo2.DataSet := frxDBDataset1; // exists on Form1, DataSet property = DataModule.FDQueryFR
Memo2.DataField := 'Birth';

// create Header band

Header := TfrxHeader.Create(Self);
Header.Parent := Page;
Header.Name := 'Header1';
Header.Height := fr01cm * 5;
Header.Visible := True;
Header.Stretched := True;

// create Memo in Header band

with TfrxMemoView.Create(Self) do
begin
Parent := Header;
Name := 'frxHeader_Memo';
SetBounds(fr01cm * 0, fr01cm * 0, fr01cm * 200, fr01cm * 5);
Memo.Text := 'Header';
end;

// create Footer band

Footer := TfrxHeader.Create(Self);
Footer.Parent := Page;
Footer.Name := 'Footer1';
Footer.Height := fr01cm * 5;
Footer.Visible := True;
Footer.Stretched := True;

// create Memo in Footer band

with TfrxMemoView.Create(Self) do
begin
Parent := Footer;
Name := 'frxFooter_Memo';
SetBounds(fr01cm * 0, fr01cm * 0, fr01cm * 200, fr01cm * 5);
Memo.Text := 'Footer';
end;

// prepare and show report

Report.PrepareReport;
Report.ShowPreparedReport;

// free report

Report.Free;

Exit;

end;

Comments

  • gpigpi
    edited 2:38AM
    Set correct Top property for all bands
  • edited 2:38AM
    gpi wrote: »
    Set correct Top property for all bands

    Hi gpi,

    your answer is correct, everything is perfect now!

    Thanks a lot,
    Rossi

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.