Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Better way to do orphan/widow in a report
Message
From
29/09/2006 10:45:01
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Title:
Better way to do orphan/widow in a report
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01158138
Message ID:
01158138
Views:
108
Hi Everyone,

One of my clients has a "high-end" report (i.e. it is a sales tool that makes them a lot of money) that they have had me implement "widow" protection on. It is a series of numbers (payments) and what they wanted accomplished is that for the last page of the report, it does not finish with just 1 line of payments on the last page (when there are multiple pages). They say "it just does not look right". So they were willing to pay for lots of hours in years gone by for me to work out hacking the .frx and figure out a way to always make sure there are 2 lines on the last page.

Under VFP7, I was able to get it to work 99.9% of the time - good enough for them. I am now converting it to VFP9 and it no longer works.

Here is what I was doing - I am open to suggestions to how to do it another way or for info/articles/3rd party products on how the report engine might have changed such that my calcs no longer work.

How I did it: hacked the .frx (using articles published in FPA etc) to:

a) figure out the header height (which grows based on a memo field so I have to use MEMLINES() to figure out how much it is going to grow and adjust)

b) figure out the footer height (which does not grow)

c) subtract these from the overall page height (10,000 units for whole page) to get the "detail area" left

d) figure out my detail row height

e) calc from that how many rows should print on a page

f) create a writable cursor and loop through it assigning expected page and line numbers to the end of the data

g) then check the last page to see if the last record falls on line #1 of that page

h) if so, skip backwards in the cursor until I find the 2nd last "payment line" (there can be blank lines and text lines as well)

i) once found, insert enough blank records before that payment line to "push" that 2nd last payment onto the last page

Like I said, works pretty well all the time but now no longer works.

Can anyone suggest:

1) a totally different way to do this - could I use "On entry/on exit" or something like that and have it fire on the 2nd last payment row and if this is on the last row of a page (such that the last payment falls on the first line of the next page), I somehow can then insert some blank records and re-run the report

2) has anyone published up-to-date articles on hacking the .frx - maybe something has changed that I now need to work into my calcs

3) is there a 3rd party product that handles orphan/widow protection or stuff like that.

Long email...sorry...any suggestions appreciated!

Albert Gostick
Guelph, ON Canada
Next
Reply
Map
View

Click here to load this message in the networking platform