I have a problem when I ran report from vb6. I use Crystal Report 8.5 as reporting tools and MySql as database for my program. When I tried to run the report in Crystal Report, it worked. But when I ran it from vb6, it showed an error: "Server has not yet been opened". Here is my codes for showing the report. Can anyone help me pliz to find the solution for my problem. Thx before.
Dim formlap1 As New lap_pembelian_barang
Dim crystal1 As CRAXDRT.Application
Dim dbTable As CRAXDDRT.DatabaseTable
Dim Report1 As CRAXDRT.Report
Dim SubReport As CRAXDRT.Report
Dim Sections As CRAXDRT.Sections
Dim Section As CRAXDRT.Section
Dim RepObjs As CRAXDRT.ReportObjects
Dim SubReportObj As CRAXDRT.SubreportObject
Dim n As Integer
Dim i As Integer
Dim j As Integer
formlap1.CRViewer1.DisplayBorder = False
formlap1.CRViewer1.DisplayTabs = False
formlap1.CRViewer1.EnableDrillDown = False
formlap1.CRViewer1.EnableRefreshButton = False
Set crystal1 = New CRAXDRT.Application
Set Report1 = crystal1.OpenReport(App.Path & "\laporan\pembelian_per_barang.rpt")
For n = 1 To Report1.Database.Tables.Count
Report1.Database.Tables(n).SetLogOnInfo "localhost", "database", user, pass
Next n
Set Sections = Report1.Sections
For n = 1 To Sections.Count
Set Section = Sections.Item(n)
Set RepObjs = Section.ReportObjects
For i = 1 To RepObjs.Count
If RepObjs.Item(i).Kind = crSubreportObject Then
Set SubReportObj = RepObjs.Item(i)
Set SubReport = SubReportObj.OpenSubreport
For j = 1 To SubReport.Database.Tables.Count
SubReport.Database.Tables(j).SetLogOnInfo "localhost", "database", user, pass
Next j
End If
Next i
Next n
Report1.DiscardSavedData
Report1.Database.SetDataSource rs
Report1.RecordSelectionFormula = "{faktur_pembelian_header.tgl_faktur}>= #" & DTPickerawal.Value & "# and {faktur_pembelian_header.tgl_faktur}<= #" & DTPickerakhir.Value & "#"
formlap1.CRViewer1.ReportSource = Report1
formlap1.CRViewer1.ViewReport
formlap1.Show
Unload Me