On 7/17/2014 1:48 PM, 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


I did this for a customer years ago in FPD2.6. I was using @say so I had a lot more control over page counters. I ran the report without printing it, saved the page numbers in variables, and then ran the report printing it with the page numbers I had saved. Worked just like the customer ordered. Don't know how it would work with the VFP9 report writer.


--
Jeff

Jeff Johnson
j...@san-dc.com
SanDC, Inc.
623-582-0323
Fax 623-869-0675

http://www.san-dc.com

_______________________________________________
Post Messages to: ProFox@leafe.com
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/53c93114.7060...@san-dc.com
** 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