Skip to Content
Dec 06, 2018 at 03:32 AM

Crystal Report XI Chart Report with VB6


i create a chart report with CR XI (Product ver :

It worked well when i try to run it from my vb6 project using crystal report viewer with this code :

Public Function prnView(ByVal rptPath As String, ByVal tblName As String, ByVal whereCondition As String, _
    Optional paramPeriod As String = "", Optional sParam As String) As Boolean

Dim vApp As New CRAXDRT.Application
Dim vRpt As New CRAXDRT.Report

Dim arTbl() As String
Dim i As Integer, j As Integer

    Screen.MousePointer = vbHourglass

    Set vRpt = vApp.OpenReport(rptPath)
    With vRpt
        arTbl = Split(tblName, "|")
        Dim ConnectionInfo As CRAXDRT.ConnectionProperties
        For i = 0 To .Database.Tables.Count - 1
            Set ConnectionInfo = .Database.Tables(i + 1).ConnectionProperties
            .Database.Tables(i + 1).ConnectionProperties.Item("Connection String") = "DRIVER={mySQL ODBC 5.1 Driver};UID=" & defUser & ";PWD=" & defPass & ";Server=" & serverName & ";port=" & defPort & ";Database=" & defDB
            .Database.Tables(i + 1).ConnectionProperties.Item("User ID") = defUser '"ztech"
            .Database.Tables(i + 1).ConnectionProperties.Item("Server") = serverName ' ""
            .Database.Tables(i + 1).ConnectionProperties.Item("Database") = defDB 'vDB ' ""
            .Database.Tables(i + 1).ConnectionProperties.Item("Use DSN Default Properties") = "False"

        .ParameterFields(1).AddCurrentValue dtpFrom.Year
        .ParameterFields(2).AddCurrentValue locSearchID

        If paramPeriod <> "" Then
            For i = 1 To .Sections.Count
                For j = 1 To .Sections(i).ReportObjects.Count
                    If .Sections(i).ReportObjects(j).Name = "strPeriod" Then
                        .Sections(i).ReportObjects("strPeriod").SetText paramPeriod
                    End If
        End If
    End With
    crView.ReportSource = vRpt
    crView.EnableGroupTree = False
    Screen.MousePointer = vbDefault

    Set vApp = Nothing
    Set vRpt = Nothing
End Function

now the problem is , when i tried to 'Stop' my vb6 project from running it always Hang and then the VB6 IDE became 'Not Responding', i can 'Stop' my project fine if i don't open The Chart Report.

here's my Project References in case i missed some References to run CR Chart Report in vb6 :

  1. Crystal ActiveX Report Viewer Library 11.5
  2. Crystal Reports ActiveX Designer Run Time Library 11.5

Thank you, and best regards.