Faceți căutări pe acest blog

joi, 29 octombrie 2015

How to move an entire band to the next page, if contains an object that spans to the next page.

Report's details can have long descriptions.
If a detail's long description overflows the page, then I see its remainder in the following page.

To avoid that and to put all the item (with its whole description) in the following page, SET REPORTBEHAVIOR 90 must be used.

This post shows a solution without subclassing the reportlistener, but it's slow and not intuitive.
Basically, the report is executed more times. Each time one more record is moved to the next page.
Because moving a single record to the next page rearrange the remaining records, the procedure must be repeated, until no record has to be moved.
The RECNO() of the records that spans to the next page, are stored into a cursor named "tproblems" (you can use other name, but you must change that name in the report; see steps 3 and 4 from below)

A demo prg with the report is attached in this rar archive containing a smal prg and a report

Description
1) the piece of code to prepare and finally show the report
*************
* Begin code
*************
CREATE CURSOR tproblems (nRec I) && cursor that retains all the record that tried to span across the pages
PRIVATE llRetry,lnReccount,llOneMoreTime,llBreak && some variables used by the report
llRetry = .T.
lnReccount = 0
SET REPORTBEHAVIOR 90
DO WHILE llRetry && because each record moved to the next page rearrange the remaining records, the procedure must be repeated one by one
    llOneMoreTime = .F.
    llBreak = .F.
    REPORT FORM MyReport TO test.txt  && test.txt can be change with any other name
    llRetry = llOneMoreTime
    lnReccount = lnReccount + 1
ENDDO
llBreak = .F.
REPORT FORM MyReport PREVIEW && the final report

*************
* End code
*************

 2) Open the report and add a new group, by llBreak and set New Page


3) Double click the field that expands to the next page, choose Field properties, and go to the Other Tab.
Click Edit Settings from the Run-time extensions.
Type llRetry in Execute When, and in the edit box above it :

*********
* Begin
*********
 if tP6 = 1 AND RECCOUNT('tproblems') = lnReccount
  insert into tproblems values (recno(ALIAS()))
  llOneMoreTime = .T.
endif

*********
* End
*********





4) Double click the Details band, choose Detail Band properties, and go to the Other Tab.
Click Edit Settings from the Run-time extensions.
Type AfterBand in Execute When, and in the edit box above it :

*********
* Begin
*********
lcAlias = ALIAS()
SELECT tproblems
LOCATE FOR nRec = RECNO(lcAlias) + 1
IF FOUND()
  llBreak = !llBreak
ENDIF
SELECT (lcAlias)


*********
* End
*********



Foxite link

Why a label from a band that span on a second page is printed in that second page, despite the Print When expression ?

Q
I have a report with one Group. In Group footer is a text field (Stretch with overflow) and a label, on the left side.
The label has the some expression on Print When (+Remove line if blank).
If the textbox from the same Group Footer overflows on second page then I see the label in second page even if it is not in first page, because the expression from Print When is evaluated to .F.
Please what is wrong?

A
You have ticked "When band content overflow to the new page/column", right above the "Remove line if blank"
Cut the expression from "Print only when expression is true", untick "When band..." and paste back the expression into "Print only when..."

Foxite link

Why stretched with overflow truncate the field from the bottom of page (the last record from the current page) ?

Q
I have a report with one Group.
In Group footer is a text field (Stretch with overflow).
If the text field extend too much I get only part of text field content in the first page and nothing else in the second page.
Please how to split text field into 2 pages if it overflow?

A
Change "Object position" from "Fix relative to the bottom of the band", into "Float"

Foxite link