oEngine = createobject("CrystalRuntime.application") oReport = oEngine.openreport(cReport,1) oReport.EnableParameterPrompting=.F. THISFORM.Report=oReport * for parameters to CR you can use the following mechanism to pass the values * to the report. Note that this asumes that the parameternames in the report * match the VFP variabele name to pass. WITH oReport.ParameterFields FOR nT= 1 TO .Count cName=.Item(nT).ParameterFieldName IF TYPE(cName) # "U" .item(nT).SetDefaultValue(EVAL(cName)) ENDIF ENDFOR ENDWITH THISFORM.CrViewer.ReportSource=oReport THISFORM.CrViewer.Viewreport()Some other tips:
DECLARE _fpreset IN msvcrt20.dll SET LIBRARY TO FOCUS.FLL * This method set the printer where the report is going to be printed on. * For more information about the functions used in this method I refer to the Focus.fll * Documentation. * The _fpreset is used to reset the numeric coprocessor to prevent errors (despite SP3) when using certain HP printerdrivers. =_fpreset() cToken= PRN_GetPrnData(ALLTRIM(cPrintername),5001) =_fpreset() cOldSep= STR_setsep(",") nTokens= STR_numtok(cToken) =_fpreset() THIS.Report.Selectprinter(STR_ntoken(6,cToken), STR_ntoken(3,cToken), STR_ntoken(5,cToken)) =_fpreset() IF PRN_GetPrnData(ALLTRIM(cPrintername),7) # nOrientation =_fpreset() oReport.paperorientation=nOrientation ENDIF =_fpreset()- Use the printout method (oReport.printout(.F.)) to actually print the report.