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

invoice printing

edited August 2002 in General
Some costumers of mine are printing invoices. and the following question is
raised :

when printing a multi page invoice we want a subtotal on the top of each
next page ( above the invoice rows )
and only a (end) total on the last page.

so my question to you ( digital metaphores )
how is this best done


yours truly,

Paul Menheere
paul@menheere.nl

Comments

  • edited August 2002
    Set LookAhead = true on a DBCalc. Set it to sum a field value in the header
    band. On the last page, set it to visible false. You'll use a twopass
    (Report.PassSetting property) report in order to know that
    Report.AbsolutePageNo = Report.AbsolutePageCount for the last page. The
    first pass determines the pagination and gets the page count for the report.
    The first pass won't work because the page count increments for each page
    that is generated, thereby, when each page generates the page number would
    alway equal the page count.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited August 2002
    okay, it's not working, I attached the rtm file and some code I used


    any help is appreciated

    What I want is following :

    I want ( if the report ( invoice ) has multiple pages ) on the first till
    last -1 to print a subtotal at the bottom of the page ( under the detail
    band ) and on the first+1 till last I want to reprint that subtotal above
    the detail band

    a crude example :

    Page 1.

    -------------------------------
    Detail BAND(S) $$$
    -------------------------------
    Subtotal of this page $$$$

    Page 2.

    subtotal of previous page $$$$
    -------------------------------
    Detail BAND(S) $$$
    -------------------------------
    Subtotal of this page $$$$$$

    Page 3 ( last )

    subtotal of previos page $$$$$$
    --------------------------------
    Detail BAND(S) $$$$
    --------------------------------

    Total of Invoice $$$$$$$$
    V.A.T : $$$$$$$


    hopes this explains it more


    Procedures i created

    procedure TRapFactuur.ppGroupHeaderBand1BeforeGenerate(Sender: TObject);
    begin
    Exit;
    with Factuur do
    begin
    if( Factuur.AbsolutePageCount > 1 ) then
    begin
    if ( Factuur.AbsolutePageNo = 1 ) then
    ( Sender as TppGroupHeaderBand).Visible := False
    else
    ( Sender as TppGroupHeaderBand).Visible := True;
    end
    else
    (Sender as TppGroupHeaderBand).Visible := False;
    end;
    end;

    procedure TRapFactuur.ppGroupFooterBand1BeforeGenerate(Sender: TObject);
    begin
    exit;
    with Factuur do
    begin
    if( Factuur.AbsolutePageCount > 1 ) then
    begin
    if ( Factuur.AbsolutePageNo = Factuur.AbsolutePageCount ) then
    ( Sender as TppGroupFooterBand).Visible := False
    else
    ( Sender as TppGroupFooterBand).Visible := True;
    end
    else
    (Sender as TppGroupFooterBand).Visible := False;
    end;
    end;
  • edited September 2002
    Send an email to support@digital-metaphors.com and we'll send you an
    example delphi project which prints this way.

    Essentially, use a TppDBCalc which resets by group, in order to calc the
    value. Set the value of a TppVariable in the group header band to be the
    value from the dbCalc. Control the visibility of the varibale to show it
    only on the subsequent pages.

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

    procedure TForm1.ppGroupHeaderBand1AfterPrint(Sender: TObject);
    begin
    varPageFooterTotal.Visible := True;
    end;

    procedure TForm1.ppGroupFooterBand1AfterPrint(Sender: TObject);
    begin
    varPageFooterTotal.Visible := False;
    end;

    procedure TForm1.ppFooterBand1BeforePrint(Sender: TObject);
    begin
    varPageFooterTotal.Value := dbcGroupTotal.Value;
    end;

    procedure TForm1.ppHeaderBand1BeforePrint(Sender: TObject);
    begin
    if ppGroup1.FirstPage then
    varPageHeaderTotal.Visible := False
    else
    varPageHeaderTotal.Visible := True;
    end;

    procedure TForm1.ppDetailBand1AfterPrint(Sender: TObject);
    begin
    varPageHeaderTotal.Value := dbcGroupTotal.Value;
    end;



    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.