Faceți căutări pe acest blog

luni, 8 februarie 2016

Unexpected behavior of a two (or more) detail band report.

Introduction
I've tried to implement the "keep lines together"  and "keep with next" option from the MS Word, into a VFP Report.

Basically in a report with two detail bands, I tried to force that both two bands to be printed in the same page. If one of the two bands expands to the next page, or one band is one page, and the second band is in the next page then I force a page break before the first band.

Here is a more detailed explanation
https://www.foxite.com/archives/description-cut-0000429585.htm

As you can see, I've found a solution, by running several time the same report. Each time, one "orphan" is moved to the next page.
The entire process is repeated until no moves are performed.

The solution is detailed in the previous link .

Then I tried to do the same trick with a four detail band.
And I discovered, by mistake, an unexpected behavior.

Description
Lets have a report that has two or more detail bands, and the report is grouped by a private memory variable. The value of that variable is changed inside the report, in the AFTERBAND or the ON EXIT event of the last detail band.
If the value of the variable is changed after the first record, then the report ends right after the first record, without showing the next records of the table.
If the value of the variable is changed only after the second record (or later), the report runs without problems, and show all the data.
The report behaves normally when it has only one detail band.
Also no problems occurs when the report is grouped by a table field, not by a memory variable.

The unexpected behavior can be reproduced by this combination: two or more details band, data are grouped by a memory variable, and the value of that variable is changed inside the report, particularly in the AFTERBAND event of the last detail band. And the change happens beginning with the first record.

Attached is a test.prg with three reports.
1) the first report c1, contains only one detail band, and behaves normally.

2) the second report c2, contains two details band, and behaves unexpected


3) the third report c2_2, contains two details band, and behaves normally
Download link
The archive containing a table, the three reports and a test.prg

Niciun comentariu:

Trimiteți un comentariu