Microsoft KB Archive/251236

= How to programmatically set the number of copies for a report =

Article ID: 251236

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 8.0 Professional Edition
 * Microsoft Visual FoxPro 9.0 Professional Edition

-



This article was previously published under Q251236



SUMMARY
In Microsoft Visual FoxPro, there is no direct way to set the number of copies to be printed. However, there are several ways to print multiple copies. One is to print the report in a loop, but this is the slowest way to do it. Another is to use the PROMPT keyword in the REPORT FORM command, but this requires an extra user action, even if it is only hitting the ENTER key. The most efficient way is to modify the .frx file directly to include the proper number of copies.

Note In Visual FoxPro 9.0, you can also use the Report Listner to set the number of copies.



MORE INFORMATION
The following code modifies a report to print the correct number of copies. To use it, save the code to a new program (named MULTIREPO.PRG, for instance) and call it from the Command window using this syntax:

DO MULTIREPO WITH [full path to report table],[number of copies wanted]

Example: DO MULTIREPO WITH "C:\MYREPORT.FRX", 2

The next time that report is printed, it prints out the number of copies you specified. LPARAMETER lcFRX, lnCopies LOCAL lcNewExpr, lnStartCopiesLine, lcStartAtCopiesLine, lnEndCopiesLine, ; lnLenCopiesLine, lcTop, lcBottom
 * 1) DEFINE vfCRLF CHR(13) + CHR(10)

IF !(UPPER(RIGHT(lcFRX, 4)) = ".FRX") lcFRX = lcFRX + ".FRX" ENDIF USE (lcFRX) LOCATE FOR objType = 1 AND objCode = 53

IF EMPTY(EXPR)

lcNewExpr = "COPIES=" + ALLT(STR(lnCopies)) + vfCRLF ELSE

lnStartCopiesLine = ATC("COPIES", EXPR) lcStartAtCopiesLine = SUBSTR(EXPR, lnStartCopiesLine) lnEndCopiesLine = ATC(vfCRLF, lcStartAtCopiesLine) lnLenCopiesLine = LEN(SUBSTR(lcStartAtCopiesLine, 1, lnEndCopiesLine)) lcTop = SUBSTR(EXPR, 1, lnStartCopiesLine - 1) lcBottom = SUBSTR(EXPR, (LEN(lcTop) + lnLenCopiesLine)) lcNewExpr = lcTop + "COPIES=" + ALLT(STR(lnCopies)) + lcBottom

ENDIF

REPLACE EXPR WITH lcNewExpr USE IN (lcFRX)

Additional query words: REPORTS

Keywords: kbhowto kbreportwriter KB251236

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.