Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Better way to do orphan/widow in a report
Message
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01158138
Message ID:
01158858
Views:
32
Hi Bo,

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.

I will need to read up on report listeners....help file is as usual, somewhat cryptic (or at least it was when my eyes were sagging last night).

From the code below, what is oProp - is it an object of the report listener?

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.

Thanks,

Albert

>Albert,
>
>Is the goal to make sure that the last 2 detail lines are always on their own page or is it to make sure there are at least 2 detail lines on a page per grouping?
>
>Either way, You may get it to work using a technique similar to this with VFP 9:
>
>- Add a column to your report cursor that identifies the 3rd from the last record for each group. Lets say "isthirdup"
>
>- Add a dummy, invisible rectangle to your detail band that is the same height as the detail band. Give it some identifying mark so you can find it in the ReportListener. Lets say add a comment "*:stretchy"
>
>- Add code to the AdjustObjectSize of the ReportListener that will identify the 3rd from the bottom record and this new rectangle
>
>- Check the oProp.MaxHeightAvailable against the oProp.Height to determine if you have 3x the space available. If not, set oProp.Height to oProp.MaxHeightAvailable
>
>
>DEFINE CLASS MyRL AS ReportListener
>
>nStretchRect = 0   && Recno of our stretchy rectangle
>...
>
>FUNCTION BeforeReport
>  ** Find the stretchy rectangle
>  SET DATASESSION TO (This.FRXDataSession)
>  SELECT frx
>  LOCATE FOR "*:stretchy" $ comment
>  IF FOUND()
>    This.nStretchRect = RECNO()
>  ENDIF
>  SET DATASESSION TO (This.CurrentDataSession)
>ENDFUNC
>
>FUNCTION AdjustObjectSize(nFRXRecNo, oProp)
>  IF nFRXRecNo = This.nStretchRect AND isthirdup
>    ** We are on the strtch rectangle and the 3rd from
>    ** the bottom record...
>    ** Do we have enough room to draw 3 detail bands?
>    IF oProp.Height*3 < oProp.MaxHeightAvailable
>      ** If not, force this band to take up all avaiable
>      ** space so the last 2 detail bands will start
>      ** on a new page
>      oProp.Height = oProp.MaxHeightAvailable
>      oProp.Reload = .T.
>    ENDIF
>  ENDIF
>ENDFUNC
>
>ENDDEFINE
>
>
>Of course there could be other factors invloved here, but maybe this will give you another approach to try.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform