Hi Albert,
>To answer the first question: the goal is to make sure that there are always 2 detail lines on the last page - the other pages typically are filled with detail lines so it is mainly the last page that I have to deal with.
OK, then the code will have to be tweaked slightly. (see below)
>From the code below, what is oProp - is it an object of the report listener?
oProp my my shorter version of oObjectProperties. See the VFP9 help file's AdjustObjectSize Method entry for more details. This property is passed to the AdjustObjectSize event from the ReportListener.
>I also don't know how to "hook" the object into the report - did not see a spot under any of the properties of the report to specify a report listener object class - maybe it is somehow invoked off the command line for REPORT FORM...will go looking this morning.
It's as easy as specifying an OBJECT clause for the REPORT FORM command. There are other options also, but this is the easiest to try it out:
oMyRL = CREATEOBJECT("MyRL")
oMyRL.ListenerType = 1 && Preview
REPORT FORM MyReport OBJECT oMyRL
I tweaked the code (unfinished) to use a seperate table to track the 3rd from the bottom record. This should have even less impact on your existing code.
DEFINE CLASS MyRL AS ReportListener
nStretchRect = 0
...
FUNCTION BeforeReport
LOCAL lcGroupExpr
SET DATASESSION TO (This.FRXDataSession)
SELECT frx
lcGroupExpr = ""
LOCATE FOR objtype=9 and objcode=4
IF FOUND()
SKIP -1
IF objcode = 3
lcGroupExpr = expr
ENDIF
ENDIF
LOCATE FOR "*:stretchy" $ comment
IF FOUND()
This.nStretchRect = RECNO()
ENDIF
SET DATASESSION TO (This.CurrentDataSession)
lnSelect = SELECT()
CREATE CURSOR curDetailBreak (recno i)
INDEX ON recno TAG recno
SELECT (lnSelect)
leLastGroupValue = EVALUATE(lcGroupExpr)
lnRecno = RECNO()
SCAN
leThisGroupValue = EVALUATE(lcGroupExpr)
IF leLastGroupValue != leThisGroupValue
lnLastRecNo = RECNO()
SKIP -1
SKIP -1
INSERT INTO curDetailBreak (recno) VALUES (RECNO())
LOCATE RECORD (lnLastRecNo)
ENDIF
leLastGroupValue = EVALUATE(lcGroupExpr)
ENDSCAN
SKIP -1
SKIP -1
INSERT INTO curDetailBreak (recno) VALUES (RECNO())
LOCATE RECORD (lnRecNo)
ENDFUNC
FUNCTION AfterReport
USE IN SELECT("curDetailBreak")
ENDFUNC
FUNCTION AdjustObjectSize(nFRXRecNo, oProp)
IF nFRXRecNo = This.nStretchRect AND SEEK(RECNO(),"curDetailBreak")
oProp.Height = oProp.MaxHeightAvailable
oProp.Reload = .T.
ENDIF
ENDFUNC
ENDDEFINE