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) ENDWITHSo 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"