Home General

Printing Child record in Parent Header

edited June 2001 in General
When using a parent-child table configuration, how do you properly
display the corresponding child field(s) in the parent's header?


I have gouping in a subreport on the child table. When the group field
changes it creates a new page.
I want to display one field from the child table in the master's header,
and it doesn't show it properly unless the query is made to to show only
one child record. If I allow the query to show more than one child, the
same field values are displayed in the parent header even though I move
through the pages.

Thanks for any hints you can provide.

John

Comments

  • edited June 2001
    The subreports traverse through as much data as possible when it prints ona
    page. When it is done printing on a page, it restores the datapipeline back
    to its original position. So, when each page begins printing, the detail
    pipeline is on the first record. Then when the subrepoirt prints, it moves
    the current record in the pipeline so it can continue printing where it left
    off on the previous page.

    One workaround is to restructure the report such that the master information
    is printed in the subreport. Use the subreport's group header instead of
    the main report's header to print the master info along with the detail
    info.

    Another alternative, if you need the layout as it is, is to simply create a
    DrawText command in the OnEndPage event of the report. This should be easy
    since the header always prints at the top of the page and the location of
    the draw command will always be in the same location.

    uses
    ppDrwCmd, ppTypes, ppUtils;

    procedure
    var
    lDrawText: TppDrawText;
    liTop: Integer;
    liWidth: Integer;
    lBitmap: TBitmap;
    begin

    lBitmap := TBitmap.Create;

    liTop := YourPositionInThousandthsOfMillimetersFromTheTopOfThePage;

    lDrawText := TppDrawText.Create(nil);
    lDrawText.Text := ppDBText1.Text;
    lDrawText.Font.Size := 10;
    lDrawText.Font.Name := 'Arial';
    lDrawText.Font.Color := clRed;
    lDrawText.Color := clAqua;
    lDrawText.Page := ppReport1.Engine.Page;
    lDrawText.Height := 3500;
    lDrawText.Left := ppReport1.PrinterSetup.PageDef.mmMarginLeft +
    (ppReport1.PrinterSetup.PageDef.mmPrintableWidth) div 2;
    lDrawText.Top := liTop;

    liWidth := lBitmap.Canvas.TextWidth(lDrawText.Text);
    liWidth := ppToMMThousandths(liWidth, utScreenPixels, pprtHorizontal,
    ppReport1.Printer);

    lDrawText.Width := liWidth;

    lBitmap.Free;

    end;

    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited June 2001
    Jim,

    Well, you confirmed what I had thought...that my report structure does not match
    the logic of what I am trying to present! I will most probably restructure the
    report, but will attempt your workaround first.

    Thanks for the excellent response and great tech support!!!! It's why I bought
    the product, and will continue to purchase upgrades, etc.


    John

  • edited July 2001
    Jim,

    Just reporting back...I was able to quickly restructure, pasting report heading
    info directly into the group header. In five minutes all was corrected.

    John

This discussion has been closed.