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.