Logon Failed!
Hi!
Please check out my code. I get this error when I 'CRViewer.ViewReport' is called.
Logon failed.
Details: ADO Error Code: 0x80030020
Source: MS OLE DB Service Components
Description: A share violation has occured
The code is pretty simple and basic. Is there anything missing or something I didn't declare?
Thanks a lot!
-----------------------------------------------------------------
Dim crxApp As New CRAXDRT.Application
Dim crxRep As CRAXDRT.Report
Dim crxDBTable As CRAXDRT.DatabaseTable
Dim crxDB As CRAXDRT.Database
Dim crxConn As CRAXDRT.ConnectionProperty
On Error GoTo ERROR_HANDLER
DoEvents
Screen.MousePointer = vbHourglass
Do
DoEvents
If CBox.GetPrinterJobs(TReport.DeviceName) <= 2 Then
Exit Do
End If
Loop
Select Case UCase(TReport.reportName)
Case "PASTDUE_SCHEDULE"
strFilename = "PDOSchedule"
Case "PASTDUE_CURRENT"
strFilename = "PDOCurrent"
Case "PASTDUE_30DAYS"
strFilename = "PDO30Days"
Case "PASTDUE_ACTIVE"
strFilename = "PDOActive"
Case "PASTDUE_SUSPENDED"
strFilename = "PDOSuspended"
Case "PASTDUE_CANCELLED"
strFilename = "PDOCancelled"
Case "PASTDUE_ABC"
strFilename = "PDOABCEmployees"
End Select
' Open crystal report printjob and get number of parameters
strFilename = UCase(App.Path & "\Reports\" & strFilename & ".rpt")
strMessage = TPastDue.Message
' Open the report
Set crxRep = crxApp.OpenReport(strFilename)
' Set database location
Set crxDBTable = crxRep.Database.Tables(1)
crxDBTable.Location = CBox.IniFileRead("Database", "Name")
' Pass parameters to report
With crxRep.ParameterFields
For i = 1 To .Count
For j = 0 To .Count - 1
If Trim(UCase(.Item(i).parameterFieldName)) = Trim(UCase(TReport.Parameters(j, 0))) Then
.Item(i).AddCurrentValue TReport.Parameters(j, 1)
Exit For
End If
Next
Next
End With
' Set printer settings
With TReport
crxRep.SelectPrinter .DriverName, .DeviceName, .Port
End With
' Set selection formula
If TReport.Filter <> "" Then
crxRep.RecordSelectionFormula = TReport.Filter
End If
Screen.MousePointer = vbDefault
With frmReportPreview.CRViewer
.ReportSource = crxRep
.ViewReport
End With
|