Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
_PageNo in VFP7,
Message
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00785952
Message ID:
00785978
Views:
12
You need to prompt for the appropriate printer and send it to a file to get an accurate page count. Try this code:
*-- Initialize variables
PRIVATE plPhantom, plPrinted, pnPages, pcTemp
plPrinted = .f.
pnPages = 0
pcTemp = SUBSTR(SYS(2015), 3, 10) + '.txt'

*-- Prompt for printer
= SYS(1037)

*-- Print the phantom report
WAIT WINDOW 'Calculating Page Count...' NOWAIT
plPhantom = .t.
REPORT FORM MyReport NOCONSOLE TO FILE &pcTemp
pnPages = _PAGENO
ERASE (pcTemp)
plPhantom = .f.
WAIT CLEAR

*-- Print the real report
IF plPrinted
  REPORT FORM MyReport TO PRINTER PROMPT PREVIEW
ENDIF
In the OnExit Expression of the Report Summary, enter the following code:
_VFP.SetVar('plPrinted', .t.)
This confirms that the report wasn't canceled by the user while processing the first phantom print. It's also important that you prompt for the printer up front so you can be assured that the same printer driver is used in the phantom print as the real print. Otherwise, you could have different unprintable margins .. which means different page counts!!

Cathy


>Hi all,
>I'am run a report in vfp7, first run:
>
>Public pnTotalPage
>REPORT FORM ref_concepto NOCONSOLE
>pnTotalPage = _PageNo
>
>********
>For obtain total page, and next run
>
>REPORT FORM ref_concepto NOCONSOLE PREVIEW
>
>And in report are include the variable pnTotalPage, but when I go to last sheet....... Page 33 of 27 ¿?.
>
>Bye.
>Matías.
Cathy Pountney, Microsoft Visual FoxPro MVP
Memorial Business Systems, Inc. (www.mbs-intl.com)

My Website: (www.frontier2000.com)
My Blog: (www.cathypountney.blogspot.com)
My Book: The Visual FoxPro Report Writer - Pushing it to the Limit and Beyond
Free MSDN Article: What's New in the VFP 9.0 Report Writer
Free MSDN Article: The VFP 9.0 Report Writer In Action
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform