>> PROCEDURE DoPreview >> WITH Thisform >> ASSERT NOT EMPTY(.cReportName) MESSAGE ; >> [Report name has not been set.] >> ASSERT NOT EMPTY(.cTableName) MESSAGE ; >> [Table name has not been set.] >> >> .BuildCRObjects() >> .AddObject("oleCRViewer", "oleControl", "crViewer.crViewer") >> ENDWITH >> >> WITH Thisform.oleCRViewer >> * Set report viewer Properties. >> .DisplayGroupTree = .F. >> .DisplayTabs = .F. >> .EnableDrillDown = .F. >> .EnableExportButton = .F. >> .EnableGroupTree = .F. >> .EnableHelpButton = .F. >> .EnableNavigationControls = .T. >> .EnablePopupMenu = .F. >> .EnablePrintButton = .F. >> .EnableRefreshButton = .F. >> .EnableSearchControl = .F. >> .EnableStopButton = .F. >> .EnableZoomControl = .T. >> .ReportSource = Thisform.oReport >> .ViewReport() >> ENDWITH >> Thisform.Show() >> ENDPROC >> >> PROCEDURE BuildCRObjects >> WITH Thisform >> .oCrystalReports = CREATEOBJECT("CrystalRuntime.Application") >> .oReport = .oCrystalReports.OpenReport(.cReportName) >> .oDB = .oReport.Database >> .oCDBT = .oDB.Tables() >> .oDBT = .oCDBT.Item(1) >> >> >> .oDBT.SetTableLocation(.cTableName,JUSTFNAME(.cTableName),"") >> =VFPDelay(2) >> .oDB.Verify() >> >> >> >> IF .oReport.HasSavedData >> .oReport.DiscardSavedData() >> ENDIF >> >> lnNumPrint = APRINTERS(laPrinters) >> IF lnNumPrint > 0 >> FOR ii = 1 TO lnNumPrint >> IF SET("PRINTER",3) = UPPER(laPrinters(ii,1)) >> .oReport.SelectPrinter(.oReport.DriverName,SET("PRINTER",3),laPrinters(ii,2)) >> EXIT >> ENDIF >> ENDFOR >> ELSE >> =GETCHOIC('There are no printing devices attached to this computer.','OK') >> ENDIF >> >> .oReport.PaperOrientation = .nOrient >> >> ENDWITH >> ENDPROC >>>>