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

Run time components still printing off page when report starts new page

edited October 2003 in General
Hi,

I am creating a report that will have several columns created at runtime
dependent on the incoming dataset structure.


The dataset has several fields that are fixed, followed by X number of
additoinal fields (all the same type and size containing a single character
string value.)

I have created a report with a sub report linked to the appropriate dataset.

The subreport contains 3 subreports

a SRNewPage
a SRHeaderLine
a SRDetailLine


The SRDetailsLine increments a counter that is used to determine whether or
not the empty SRNewPage will start a new page or not.

The SRHeaderLine only prints when the Counter = 0 (ie new page start)

The SRDetailLine is set to shift relative to the SRHeaderLine, which in turn
is set to Shiftrelative to the SRnewPage.

The form with the report component creates in addition to the static labels
/ dataaware labels representing the static fields
1. a series of vertical lines / header labels in the SRHeaderLine to
represent the dynamic fields.
2. a correspondng series of vertical lines / dataaware labels in the
SRDetailLine to represent the dynamic fields.


This works great - the report starts a new page as expected after the
required number of lines, the headers print perfectly, the dataaware
components display the correct data.

HOWEVER, the dynamic dataaware components continue to be printed on the
whitespace at the bottom of the report and off the page! even though the
dynamic lines do not.



Here is the code for preparing the dynamic content

procedure TFormHearingDates2.PrepareReport;
var i : integer;
LineHeight, StartWitnessFrom, WitnessWidth, WitnessSep : Real;

lLabel: TppLabel;
lDBText: TppDBText;
lDiv, lDivHdr : TppLine;

begin
StartWitnessFrom := 4.1354;
WitnessWidth := 0.11;
WitnessSep := 0.03;
LineHeight := 0.1250;

//set width lines


//set witness left and right
//ppLWitness


for i := 1 to FormCalendar.TotalWitness do
begin
{need to create a TppLabel in header band and TppDBText in detail
band}
lLabel := TppLabel.Create(ppReport1);
lLabel.AutoSize := True;
//lLabel.Width := WitnessWidth;
lLabel.Caption := format ('%d',[i]);

lLabel.Band := ppDetailBand6;
lLabel.Left := StartWitnessFrom + (WitnessWidth *i) + ( WitnessSep *
(i-1) );
lLabel.Top := 0.2396;
lLabel.Font.Size := 6;
lLabel.Font.Color := clBlack;
lLabel.Font.Name := 'Times New Roman';
lLabel.ReprintOnOverFlow := True;
lLabel.ShiftWithParent := True;

lDivHdr := TppLine.Create(ppReport1);
lDivHdr.Left := StartWitnessFrom + (WitnessWidth *(i + 1 ) ) + (
WitnessSep * (i-1) ) - (WitnessSep/2) ;
lDivHdr.Top := 0.1979;
lDivHdr.Height := LineHeight ;
lDivHdr.Position := lpLeft;
lDivHdr.Width := 2;
lDivHdr.Band := ppDetailBand6;
lDivHdr.ReprintOnOverFlow := True;
lDivHdr.ShiftWithParent := True;


lDBText := TppDBText.Create(ppReport1);
lDBText.AutoSize := True;
//lDBText.Width := WitnessWidth;
lDBText.DataField := format ('Wit%d',[i]);
lDBText.DataPipeline := ppDBCaseData;
lDBText.Band := ppDetailBand7;

lDBText.Font.Size := 6;
lDBText.Font.Color := clBlack;
lDBText.Font.Name := 'Times New Roman';
lDBText.Left := StartWitnessFrom + (WitnessWidth *i) + ( WitnessSep
* (i-1) );
lDBText.Top := 1;
lDBText.Height := 15;
lDBText.WordWrap := False;

lDiv := TppLine.Create(ppReport1);

lDiv.Left := StartWitnessFrom + (WitnessWidth * (i + 1 )) + (
WitnessSep * (i-1) )- (WitnessSep/2);
lDiv.Top := 0;
lDiv.Height := LineHeight ;
lDiv.Position := lpLeft;
lDiv.Width := 3;
lDiv.Band := ppDetailBand7;

end;
end;


Here is the code associated with one of the shapes on the SRDetailLine, that
also INC the counter (The counter is reset before printing is started)

procedure TFormHearingDates2.ppShape1Print(Sender: TObject);
begin
inherited;
ppShape1.Brush.Color :=
FormCalendar.FindWindowColour(ppDBCaseData.FieldValues['Window'],ClWhite);
INC ( CurrentRows ) ;
end;


Here is the code for forcing a new page - This is on the SubReport Detail
containing the three SubReports

procedure TFormHearingDates2.ppDetailBand4BeforePrint(Sender: TObject);
begin
inherited;
if CurrentRows >= RowsPerPage then
begin
CurrentRows := 0;
ppTitleBand6.NewPage := True;
end
else
begin
ppTitleBand6.NewPage := False;
end;
end;



Please help!!!!

Can anyone tell me why the dynamic dataware labels are printing in the
whitespace below the last expected line even though the rest of the
components on the SRDETAILline band are not!

ie.
START OF PAGE

header line STATIC1 STATIC2 STATIC3 Line1 DYNAMICDB1 Line2 DYNAMICDB2
Line3 DYNAMICDB3

Detail Line STATIC1 STATIC2 STATIC3 Line1 DYNAMICDB1 Line2 DYNAMICDB2
Line3 DYNAMICDB3
Detail Line STATIC1 STATIC2 STATIC3 Line1 DYNAMICDB1 Line2 DYNAMICDB2
Line3 DYNAMICDB3
Detail Line STATIC1 STATIC2 STATIC3 Line1 DYNAMICDB1 Line2 DYNAMICDB2
Line3 DYNAMICDB3
Detail Line STATIC1 STATIC2 STATIC3 Line1 DYNAMICDB1 Line2 DYNAMICDB2
Line3 DYNAMICDB3
Detail Line STATIC1 STATIC2 STATIC3 Line1 DYNAMICDB1 Line2 DYNAMICDB2
Line3 DYNAMICDB3 <- expected end of lines - new page start point

Detail Line
DYNAMICDB1 DYNAMICDB2 DYNAMICDB3
Detail Line
DYNAMICDB1 DYNAMICDB2 DYNAMICDB3
Detail Line
DYNAMICDB1 DYNAMICDB2 DYNAMICDB3
Detail Line
DYNAMICDB1 DYNAMICDB2 DYNAMICDB3
Detail Line
DYNAMICDB1 DYNAMICDB2 DYNAMICDB3
Detail Line
DYNAMICDB1 DYNAMICDB2 DYNAMICDB3

END OF PAGE
This discussion has been closed.