TechNet
Products
IT Resources
Downloads
Training
Support
Products
Windows
Windows Server
System Center
Microsoft Edge
Office
Office 365
Exchange Server
SQL Server
SharePoint Products
Skype for Business
See all products »
Resources
Channel 9 Video
Evaluation Center
Learning Resources
Microsoft Tech Companion App
Microsoft Technical Communities
Microsoft Virtual Academy
Script Center
Server and Tools Blogs
TechNet Blogs
TechNet Flash Newsletter
TechNet Gallery
TechNet Library
TechNet Magazine
TechNet Wiki
Windows Sysinternals
Virtual Labs
Solutions
Networking
Cloud and Datacenter
Security
Virtualization
Updates
Service Packs
Security Bulletins
Windows Update
Trials
Windows Server 2016
System Center 2016
Windows 10 Enterprise
SQL Server 2016
See all trials »
Related Sites
Microsoft Download Center
Microsoft Evaluation Center
Drivers
Windows Sysinternals
TechNet Gallery
Training
Expert-led, virtual classes
Training Catalog
Class Locator
Microsoft Virtual Academy
Free Windows Server 2012 courses
Free Windows 8 courses
SQL Server training
Microsoft Official Courses On-Demand
Certifications
Certification overview
Special offers
MCSE Cloud Platform and Infrastructure
MCSE: Mobility
MCSE: Data Management and Analytics
MCSE Productivity
Other resources
Microsoft Events
Exam Replay
Born To Learn blog
Find technical communities in your area
Azure training
Official Practice Tests
Support options
For business
For developers
For IT professionals
For technical support
Support offerings
More support
Microsoft Premier Online
TechNet Forums
MSDN Forums
Security Bulletins & Advisories
Not an IT pro?
Microsoft Customer Support
Microsoft Community Forums
Sign in
Home
Library
Wiki
Learn
Gallery
Downloads
Support
Forums
Blogs
Resources For IT Professionals
United States (English)
Россия (Pусский)
中国(简体中文)
Brasil (Português)
Skip to locale bar
Post an article
Translate this page
Powered by
Microsoft® Translator
Wikis - Page Details
First published by
EnglishBob2
When:
8 Mar 2013 5:37 AM
Last revision by
Richard Mueller
(cMVP, Microsoft Community Contributo)
When:
2 Apr 2013 3:56 PM
Revisions:
3
Comments:
1
Options
Subscribe to Article (RSS)
Share this
Can You Improve This Article?
Positively!
Click Sign In to add the tip, solution, correction or comment that will help other users.
Report inappropriate content using
these instructions
.
Wiki
>
TechNet Articles
>
VFP - Getting Number of Pages For a Group When Page Numbers Start at 1 Per Group
VFP - Getting Number of Pages For a Group When Page Numbers Start at 1 Per Group
Article
History
VFP - Getting Number of Pages For a Group When Page Numbers Start at 1 Per Group
A question arose in the VFP forum concerning printing data within the Page Footer area that relates to the current group, rather than within the Group Footer.
I showed how to do this, but at the time could not address how to get the number of pages used for each group when page numbering is reset to 1 for each group. In other words how to obtain N for the normal "Page 1 of N" given at the bottom of a page. Well now I have a way to do it. All within the report using an array and array subscript variable.
1) Create a report variable - say RptArrSub - used to index the array to hold the last page number per group.
Set "Initial Value" to 0 and "Value to Store" to RptArrSub. This retains its value when each record in the report cursor is processed.
2) On the Reports Property window click the Other tab and then Edit settings within Run-time extensions.
Put In Execute when: BeforeReport
and the following code into the script after the lparameters list.
* force a two pass process
toListener.TwoPassProcess = .T.
* when starting the report
IF toListener.currentpass = 0 then
* release the array if it already exists
RELEASE rptarry1
* create the array as Public and set its intial value
PUBLIC rptarry1[1]
store 1 to rptarry1[1]
endif
3) In the Properties window of the Group Header Band, click the Other tab and then Edit Settings in Run-time extensions.
Put in Execute When: BeforeBand
Now in the Run-time extensions: code after the lparameters list put
* increment the array index variable
store (RptArrSub + 1) to RptArrSub
* increase the dimension of the array, but only on the first pass
IF toListener.currentpass = 0 and ALEN(rptarry1,1) < RptArrSub then
DIMENSION rptarry1[RptArrSub]
store 1 to rptarry1[RptArrSub]
endif
4) In the Properties window of the Group Footer Band click the Other tab and then Edit Settings in Run-time extensions. In Execute When: put BeforeBand
Now in the Run-time extensions: code after the lparameters list put
* check it is the first run of a 2 pass print process
if toListener.currentpass = 0 then
if ALEN(rptarry1,1) < RptArrSub then
* not much we can do here
else
* save the current page number into the array
store _pageno to rptarry1[RptArrSub]
endif
endif
5) Now add a Field to the report in the PageFooter and set its Expression to
"Page " + ALLTRIM(STR(_PAGENO)) + " of " + iif(rptarrsub >0 and rptarrsub <= alen(rptarry1,1) , str(rptarry1[rptarrsub],3), "??")
Now when you require a report in which a data group restarts page numbering at 1, you do not need to lose the "Page 1 of N" element at the bottom of each page.
Data Groups
,
en-US
,
has code
,
PageNo
,
Reporting
,
VFP9
,
Visual FoxPro
[Edit tags]
Leave a Comment
Please add 2 and 6 and type the answer here:
Post
Wiki - Revision Comment List(Revision Comment)
Sort by:
Published Date
|
Most Recent
|
Most Useful
Comments
Richard Mueller
2 Apr 2013 3:56 PM
Richard Mueller edited Revision 1. Comment: Modified title, added tag
Edit
Page 1 of 1 (1 items)
Wikis - Comment List
Sort by:
Published Date
|
Most Recent
|
Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
Posted by
Richard Mueller
on
2 Apr 2013 3:56 PM
Richard Mueller edited Revision 1. Comment: Modified title, added tag
Edit
Page 1 of 1 (1 items)