Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Print Dialog Box
Message
 
À
24/08/2005 12:16:14
Steve Jones
Business Systems Services Uk Ltd
Swansea, Royaume Uni
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 6 SP5
Divers
Thread ID:
01041633
Message ID:
01043711
Vues:
32
This message has been marked as the solution to the initial question of the thread.
>Thanks for looking at this problem for me.
>
>How would I implement this code into my solution. Would I need to create a new class or would I modify the existing reportformprompt.scx? If so how would I do this?
>Steve

Steve,
This is the same form you downloaded from Microsfot site I pointed to. I only add one checkbox named FilePrint with caption "To File" and with value = .f., then I change only PrintReport Method to this:
LOCAL lcOldPrinter, lnPrintRangeFrom, lnPrintRangeTo, lcWhere_For, lcScope, lcFileName

WITH THISFORM

   *!* Someone choose the file exit
   IF thisform.FilePrint.Value
      lcFileName = PUTFILE("Choose File Name",JUSTSTEM(.RptTmpFile),"PRN")
      IF EMPTY(lcFileName) && No file is selected
         RETURN
      ENDIF
      lcFileName = FORCEEXT(lcFileName,"PRN")     
   ENDIF 

   *!*	Set the user defined scope and WHERE/FOR clauses
   lcForWhile = .cForWhile
   lcScope = .cScope
   *!*	 Prepare the print range.  If all pages (opgPrintRange = 1),
   *!*	 then use 1,9999 otherwise use the form properties
   lnPrintRangeFrom = IIF(.opgPrintRange.VALUE = 1, 1, .txtPageFrom.VALUE)
   lnPrintRangeTo = IIF(.opgPrintRange.VALUE = 1, 9999, .txtPageTo.VALUE)

   *!*	Remember the current FoxPro printer setting
   lcOldPrinter = SET('PRINTER', 3)
   SET PRINTER TO NAME(.printername)
   *!*	Run either the LABEL FORM or the REPORT FORM
   DO CASE
   CASE .RptExt = "FRX"
        IF thisform.FilePrint.Value
           ** Print Report to File
           REPORT FORM (.RptTmpFile) TO FILE (lcFileName);
                       &lcForWhile ;
                       &lcScope ;
                       NOCONSOLE ;
                       RANGE lnPrintRangeFrom,lnPrintRangeTo
        ELSE
           ** Print Report to Printer
           REPORT FORM (.RptTmpFile) TO PRINTER ;
                       &lcForWhile ;
                       &lcScope ;
                       NOCONSOLE ;
                       RANGE lnPrintRangeFrom,lnPrintRangeTo
        ENDIF
   CASE .RptExt = "LBX"
        IF thisform.FilePrint.Value
           ** Print Label to File
           LABEL FORM (.RptTmpFile) TO FILE (lcFileName);
                 &lcForWhile ;
                 &lcScope ;
                 NOCONSOLE ;
                 RANGE lnPrintRangeFrom,lnPrintRangeTo

        ELSE
           ** Print Label to Printer
           LABEL FORM (.RptTmpFile) TO PRINTER ;
                 &lcForWhile ;
                 &lcScope ;
                 NOCONSOLE ;
                 RANGE lnPrintRangeFrom,lnPrintRangeTo
        ENDIF
   OTHERWISE
      =MESSAGEBOX("Cannot print report")
   ENDCASE
   SET PRINTER TO NAME(lcOldPrinter)
ENDWITH
So there where you print report you must do:
* Check Init event of the form for more info about parameters
DO FORM ReportFormPrompt WITH "ReportName.FRX" 
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform