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

Keep last detail and summary together

edited January 2002 in General
Hi,

this must be simple, but I can't figure out how to achieve it.

I don't want the summary band to print just after a page break. I mean,
if the last detail and the summary don't fit in the page, I want the
report to apply a page break, and the print the last detail and the
summary together.

--
Regards,
Francisco Sanchez
fmsanchez@telecable.es

Comments

  • edited January 2002
    You'll have to move the draw commands of the last detail band to the next
    page. Then you'll have to shift the draw commands for the summary down on
    the page in order to make room for the detail band. To determine if the
    summary band doesn't fit on a page, use a region in the summary band and set
    it to KeepTogether = True. Then in the summary band's after print event,
    check the SummaryBand.OutOfSpace property. If it is true, then the summary
    band ran out of space trying to print on the current page, and then it will
    print on the next page.

    To rearrange the draw commands, you'll have to store handles to each of the
    draw commands for the detail band in a TList. Use their OnDrawCommandCreate
    event, to get a handle to the instantiated draw command. Then stick these in
    a TList. Clear the list everytime another detail band prints. Create
    another list for the draw commands of the summary band. Now, you can
    determine when the detail prints on a different page than the summary band.
    Use the Report.OnEndPage (currently on the summary band page) event to loop
    through the detail band draw command list. Set these draw command's Page
    proeprties to the current page Report.Engine.Page. Alos loop through them
    and set thier top propertiew to an offset value so that they will be at the
    top of the page, underany headers. Then loop through the summary band TList
    for the draw commands and shift them down below the detail band.

    The units of measure for the positions are in microns (thousandths of
    millimeters). There are a couple of conversion routines in ppUtils.
    ppToMMThousandths and ppFromMMThousandths.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited January 2002
    Hi,

    In article <8EAE82296ACCD311A039005004E0CAC0062DE3@DMSERVER>,
    support@digital-metaphors.com says...

    It sounds really complex. I think you should implement in future versions
    an 'AllowOrphans' property for SummaryBand and GroupFooter bands. In my
    opinion an orphan subtotal or total band is really ugly. I have created
    several great looking reports with ReportBuilder in these years with
    only this flaw, and I really thought that with the 'KeepTogether'
    property this could be easily addressed now (I was working with Delphi 3
    so I didn't have the opportunity to use it).

    --
    Regards,
    Francisco Sanchez
    fmsanchez@telecable.es
  • edited January 2002
    This draw command reordering approach is going to be more complicated,
    because, you'll have to generate the pages to cache, and then reorder the
    draw commands, and then send the pages to the output device.

    Another approach (much simpler), is to use the fact that TppVariables will
    have their OnCalc events triggered, even if they are are to visible = false.
    I wonder if you could place the summary band info in the detail band, but
    only set it to visible = true in the last detail band's BeforePrint event.
    You could determine if the detail band is the last by checking if the
    current record number in the datapipeline is equal to the total record
    count.

    Place all of the controls in the detail band (including the invisible
    summary controls) inside of a stretching KeepTogether region. Use variables
    and their OnCalc events to code the calculations for the summary
    information.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.