what seems to be wrong with my code... my crystral report viewer was very slow on it first load...
pls. review my code.. thanks,
alexis23
VB Code:
Private Sub Form_Load() Dim sSQL As String CRViewer1.Top = 0 CRViewer1.Left = 0 CRViewer1.EnableExportButton = gstrRptExport sSQL = gstrRptCmd ' gstrrptcmd is a global variable that holds a sql statement Me.Caption = gstrRptTitle If Dir(gstrRptPath) = "" Then MsgBox "Report file not found!", vbCritical GoTo ReportErr End If If sSQL = "" Then MsgBox "Invalid data retrieval!", vbCritical Exit Sub End If On Error GoTo ReportErr Set cn = New ADODB.Connection cn.CursorLocation = adUseClient cn.Open gstrConnectString Set oRS = New ADODB.Recordset oRS.LockType = adLockReadOnly oRS.CursorType = adOpenStatic oRS.Open sSQL, cn, adOpenStatic, adLockReadOnly oRS.Requery Set oApp = New CRAXDRT.Application Set oReport = oApp.OpenReport(gstrRptPath, 1) oReport.DiscardSavedData oReport.Database.SetDataSource oRS, 3, 1 oReport.PaperSize = oReport.PaperSize oReport.PaperOrientation = oReport.PaperOrientation Screen.MousePointer = vbHourglass CRViewer1.ReportSource = oReport CRViewer1.ViewReport Do While oReport.PrintingStatus.Progress = crPrintingInProgress 'DoEvents Loop Screen.MousePointer = vbDefault Exit Sub ReportErr: MsgBox err.Description Exit Sub end sub




Reply With Quote