Microsoft KB Archive/251236: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
 
Line 67: Line 67:


</div>
</div>
Example: DO MULTIREPO WITH &quot;C:\MYREPORT.FRX&quot;, 2<br />
Example: DO MULTIREPO WITH "C:\MYREPORT.FRX", 2<br />
<br />
<br />
The next time that report is printed, it prints out the number of copies you specified.
The next time that report is printed, it prints out the number of copies you specified.
Line 75: Line 75:
#DEFINE vfCRLF CHR(13) + CHR(10)
#DEFINE vfCRLF CHR(13) + CHR(10)


IF !(UPPER(RIGHT(lcFRX, 4)) = &quot;.FRX&quot;)
IF !(UPPER(RIGHT(lcFRX, 4)) = ".FRX")
     lcFRX = lcFRX + &quot;.FRX&quot;
     lcFRX = lcFRX + ".FRX"
ENDIF
ENDIF
USE (lcFRX)
USE (lcFRX)
Line 83: Line 83:
IF EMPTY(EXPR)
IF EMPTY(EXPR)


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


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


ENDIF
ENDIF

Latest revision as of 13:51, 21 July 2020

Knowledge Base


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
#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