hello guys! just got some problem generating a crystal report with SQL server as database and vb6 as backend. Whenever i call the report for the "FIRST" time, the error doesn't appear however when i try to generate the report again, the above error appears. Pls give me some hints pls. Below is my code:
Code:
Call LoadReport
Screen.MousePointer = vbHourglass
CRViewer91.ReportSource = Report
CRViewer91.ViewReport
Screen.MousePointer = vbDefault
' Set Report Group Section
Set oSectionGH = Report.Sections("D") 'this where the error occurs.
Code:
Private Sub oSectionGH_Format(ByVal pFormattingInfo As Object)
If Dir(App.Path & "\" & oSectionGH.ReportObjects(2).Value & ".jpg") <> "" Then
Set oSectionGH.ReportObjects.Item("picImage").FormattedPicture = LoadPicture(App.Path & "\" & oSectionGH.ReportObjects(2).Value & ".jpg", vbLPCustom, vbLPColor)
Else
Set oSectionGH.ReportObjects.Item("picImage").FormattedPicture = LoadPicture(App.Path & "\" & "blank.jpg", vbLPCustom, vbLPColor)
End If
End Sub
Code:
Sub LoadReport()
Dim strConnString As String
strConnString = vbNullString
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\" & "NWIND.mdb;Persist Security Info=False"
Set Crystal = New CRAXDRT.Application
Set Report = New CRAXDRT.Report
Set adoRec = New ADODB.Recordset
With adoRec
.ActiveConnection = strConnString
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.LockType = adLockReadOnly
.Source = "SELECT * FROM CUSTOMERS"
.Open
End With
Set Report = Crystal.OpenReport(App.Path & "\" & "sample.rpt", 0)
With Report
.DiscardSavedData
.Database.SetDataSource adoRec
.VerifyOnEveryPrint = True
End With
End sub