Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Better way to do orphan/widow in a report
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01158138
Message ID:
01158442
Vues:
33
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform