Hi Bo,
More good ideas! Just about quitting time but I scanned below and will work it in tomorrow.
Here are a couple of things I just figured out:
1) the other objects in the band have to have their property set to "Fix relative to bottom" (I think - at least that is what worked for me).
2) I had to set the height of the box to Max height + 1 - to force the band to the next page
3) your code below no longer compares the height of the box to the max height available - just a skip or for some reason did your logic change on this?
Thanks for the help...back at it tomorrow.
Albert
>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
>
> ** Find the stretchy rectangle
> SET DATASESSION TO (This.FRXDataSession)
> SELECT frx
>
> ** Find the Group expression
> lcGroupExpr = ""
> LOCATE FOR objtype=9 and objcode=4
> IF FOUND()
> SKIP -1
> IF objcode = 3
> lcGroupExpr = expr
> ENDIF
> ENDIF
>
> ** Find the dummy rectangle
> LOCATE FOR "*:stretchy" $ comment
> IF FOUND()
> This.nStretchRect = RECNO()
> ENDIF
> SET DATASESSION TO (This.CurrentDataSession)
>
> ** Create a temp table to track our 3rd from the bottom
> ** record for each group
> lnSelect = SELECT()
> CREATE CURSOR curDetailBreak (recno i)
> INDEX ON recno TAG recno
> SELECT (lnSelect)
>
> *! ToDo: FInish this code
> ** Scan through the cursor looking for group
> ** changes and insert the 3rd from the bottom RECNO()
> ** of each group into curDetailBreak
> leLastGroupValue = EVALUATE(lcGroupExpr)
> lnRecno = RECNO()
> SCAN
> leThisGroupValue = EVALUATE(lcGroupExpr)
> IF leLastGroupValue != leThisGroupValue
> ** Save the current record position
> lnLastRecNo = RECNO()
> ** go back 2 records
> SKIP -1
> SKIP -1
> ** store the recno in the temp cursor
> 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
> ** Close the temp table
> USE IN SELECT("curDetailBreak")
>ENDFUNC
>
>
>FUNCTION AdjustObjectSize(nFRXRecNo, oProp)
> IF nFRXRecNo = This.nStretchRect AND SEEK(RECNO(),"curDetailBreak")
> ** We are on the stretch rectangle and the 3rd from
> ** the bottom record...
> ** Force a new page by making the rectangle equal to
> ** the max size
> oProp.Height = oProp.MaxHeightAvailable
> oProp.Reload = .T.
> ENDIF
>ENDFUNC
>
>ENDDEFINE
>