Many thanks for the feedback, Kevin!

#1 looks most promising...#2 won't work as there is a memo field printed (if it contains text) so the # of records on a page varies. I agree that #3 looks like overkill! Before I would dive headfirst into the report listener I would just generate multiple reports...hey! #1!

FWIW, I also tried running the report twice (runs fast, not a problem with speed) and storing the page # when the group would break in a separate table created by the function called from the group-by footer band. Again, worked great on my development machine but once compiled and deployed to a run-time workstation I got a lot of very odd errors (variables missing, files not found) and one half of one page output.

Mike Copeland

Kevin Cully wrote:
Hey Mike,

I had to load up VFP Help to try to get on track with what you are saying but I'm thinking of a couple of possible solutions:

1. There's a way of chaining reports together. You could run a report for each sales person, but chain them together so it runs them and they appear as one print job. I haven't ever really done this but it's worth looking into. Look into the REPORT FORM ... [NOPAGEEJECT] and [NOEJECT] options to see which ones will apply. I like the thought of this approach as you're using the 'natural' report behavior, you're just creating multiple reports programmaticly.

2. Another possible solution would be to pre-calculate how many records will show per page, and then pre-populate a page number field, and a page total field in the dataset before feeding the data to the report itself. This would be reliant on a simple report layout. (No stretching memo fields to mess things up, etc.)

3. You could do something crazy with the report listener, that would run the report first to help you calculate the page totals per salesperson, and then run the report again out to PREVIEW or the normal output. This seems pretty complicated and would increase the time that is needed to get the report output, but if this is what they want, then it's an option. I used to do some of this but it has been a very very long time and has been lost in the fog of my memory. Some experimentation would tell you what is feasible.

Good luck and tell us how things progress along.

-Kevin


On 07/17/2014 05:28 PM, Mike Copeland wrote:
Executive Summary:

Anyone have a solution for "Page X of XX" where XX is reset when the group-by changes on a VFP report?

Mike Copeland

Mike Copeland wrote:
All,

I have a report of sales grouped by Sales Person.
The page # resets as the group (Salesperson) changes... "Page 1" "Page 2" "Page 1" etc. Works great. My client wants it to show "Page 1 of 2" "Page 2 of 2" and then when the group/salesperson changes, "Page 1 of 3" "Page 2 of 3" as appropriate.

Using the "_PageTotal" system variable for an entire report works fine.
VFP does a double-run of the report to get the total # of pages...not a problem.
But there's no way to reset it on the Group break (that I know of.)

So I Googled a "solution" for the Group _PageTotal problem, and it works on my development computer. When I run it on the client's workstation, it has a problem...I get "File Not Found" when the function is called.

The solution I'm using is:
1. add a function call in the group footer band, i.e., "countpages(staffname,_pageno)" 2. add a column in the report source table "reportsource" to contain the group page count, "ofpages" 3. create a function (I put it in my main startup application but it works as a method on the calling form, too)
        function countpages
        parameter pStaffName, pOfPage
update dbf("reportsource") set OfPages = pOfPage where allt(staffname)=allt(pStaffName)
            return ''
        endfunc

The problem is that when run on client's system (Win XP or Win7) I get a "File not found" referring to the reportsource table reference in the function call. It also includes a randomly generated file name... due to reportsource being a cursor.

What I've tried:
1. Changed the reportsource from a cursor to a table
Select yadda yadda into TABLE reportsource (instead of "into CURSOR reportsource") This DID eliminate the "file not found" problem, but it also caused the function to "fail" after just a few calls. In other words, it acted okay, but the reportsource table only had about 7 of the 1,500 records updated (the ofpages field). The rest were still set to 0 (what they were initialized as.)

2. I moved the function from the main application file to a method on the form that initiates the report activity.
    No change.

3. I tried setting the datasession in the calling form, and in the CountPages function. No change. The datasessions are the same (based on WAIT windows I added to popup and indicate the datasessionid at various steps.)

4. I double-checked the "Temp" workfile settings. Still not 100% sure this is not the source of the problem.

I'm at a loss. Any ideas or is anyone successfully using a workaround for the group+_pagetotal problem? I've read several articles, including one by Cathy Pountny. Nothing so far...

Thanks for any pointers!
Mike Copeland


[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to