How to make QR Page Footer or Band to be under Band Details not at the page end?

3.8k Views Asked by At

I need to make report, that has summary after Details had printed, not after every each Detail.

I only know the Page Footer, but it's at page bottom not after the Detail Band.

Is there a QRBand that could go after Detail Band? Or can you make PageFooter height resize on every page?

3

There are 3 best solutions below

6
On BEST ANSWER

Summary Bands print only at the end of the report immediately after the last 'detail' (unless the AlignToBottom property is set to true).

You should add a TQRBand to the report and set the BandType property to rbSummary.


EDIT

If you need to show intermediate results on every page you could add the FooterBand and the SummaryBand.

enter image description here

Summary Bands prints only at the end of the report (last page) and you can use the BeforePrint event of the summary to disable the footer band.


EDIT2

You can also try with a QRGroupBand and a QRFooterBand.

In the GroupBand:

  • use the Expression property for separating one group of products from another (the band could also be empty)
  • set appropriately the FooterBand property. This is where you link the header band to the correct footer band and encapsulate your group inside. Place the header band first and then go back and place the footer band by dropping a QRBand component and immediately changing the Type from rbTitle to rbGroupFooter. Once you have done this, you can go back to the QRGroup header and select the right footer band to use.

The FooterBand is where you are printing summary totals for each product.

0
On

Add a GroupHeader and a GroupFooter to the report. Make the Expression on the GroupHeader = PAGENUMBER, and set Height = 0; in it's BeforePrint event handler, so that it never shows. Set the GroupHeader's FooterBand property to the GroupFooter band. Then put your page totals or whatever on the GroupFooter. This will print after the detail on every page, and the Summary will print after that on the last page!

0
On

I was able to solve the problem with the help of quickreport events and datasource events. In a test project, it is enough to put a tqrlabel in the pagefooter, the rest is written below.

type
TForm1 = class(TForm)
  ...
private
  firstValue: Integer;
public
  counter: Integer;
end;

var
  Form1: TForm1;
  PageSummery: Integer;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Application.CreateForm(TForm2, Form2);
  adoquery.First;
  counter := 0;
  firstValue := adoquery.FieldByName('id').AsInteger;
  PageSummery := 0;
  Form2.QuickRep1.Preview;
  Form2.Free;
end;

procedure TForm1.adoqueryAfterScroll(DataSet: TDataSet);
begin
  if counter <= 1 then
    PageSummery := firstValue + adoquery.FieldByName('id').AsInteger
  else
  begin
    PageSummery := PageSummery + adoquery.FieldByName('id').AsInteger;

    form2.QRLabel2.Caption := IntToStr(PageSummery - Form1.adoquery.FieldByName('id').AsInteger);
  end;
counter := counter + 1;
end;

Pay attention to the location of the variables in the first form. The first button is used to fill the query data. After each increase, the data is placed in the qrlabel so that all the data is saved when the event is triggered. The final point is in the quickreport event, which occurs before filling the print rows when creating a new page. In this event, a number of variables must be set to zero.

procedure TForm2.QuickRep1StartPage(Sender: TCustomQuickRep);
begin
  if Form1.counter = 0 then
    PageSummery := 0
  else
    PageSummery := Form1.adoquery.FieldByName('id').AsInteger;
end;