Link to home
Start Free TrialLog in
Avatar of srequena
srequena

asked on

Set Application = CreateObject("CrystalRuntime.Application") Error

I have a Visual Basic 6 Application that has a form with a Crystal Reports Viewer Control.  I am receiving an Error No.13 Type Mismatch Error on the line marked below:
........
Dim Application As CRAXDRT.Application
Dim Report As CRAXDRT.Report

Public Sub CreateReport(strReport As String, Optional crossing As Variant)
On Error GoTo errhandler
    strCounty = ""
    strSelectionFormula = ""
    Set Application = CreateObject("CrystalRuntime.Application")  ' Error Occurs here

I have a Crystal Report Viewer Control Component and references to the following files:

Crystal Reports 8.5 ActiveX Designer Run Time Library - C:\Program Files\Seagate Software\Report Designer Component\.......
Crystal Report Viewer Control - C:\Program Files\Microsft Visual Studio\VB98\crviewer.oca
Crystal Reports 8.5 library      C:\Program Files\Seagate Software\Report Designer Component\.......

Please help me figuring out why I am  getting that error and how to solve it.

Thanks

Option Explicit
Dim strSelectionFormula As String
Dim Cancel As Boolean
Dim strCounty
Dim Application As CRAXDRT.Application
Dim Report As CRAXDRT.Report
 
Public Sub CreateReport(strReport As String, Optional crossing As Variant)
On Error GoTo errhandler
    strCounty = ""
    strSelectionFormula = ""
    Set Application = CreateObject("CrystalRuntime.Application")
 
    'The RecordSelectionFormula is basically setting the WHERE clause of the report
    If strReport = "Top_100" Then
        frmReport.Caption = "Top 100 Hazard Rating's"
        Set Report = Application.OpenReport(App.Path & "\Database\Hazard Ratings.rpt")
        strSelectionFormula = "{V_XRRK_CROSSTAB.REPORT_RANK} <= 100"
                                                                                                                    
    ElseIf strReport = "Top_200" Then
        frmReport.Caption = "Top 200 Hazard Rating's"
        Set Report = Application.OpenReport(App.Path & "\Database\Hazard Ratings.rpt")
        strSelectionFormula = "{V_XRRK_CROSSTAB.REPORT_RANK} <= 200"
        
    ElseIf strReport = "Top_300" Then
        frmReport.Caption = "Top 300 Hazard Rating's"
        Set Report = Application.OpenReport(App.Path & "\Database\Hazard Ratings.rpt")
        strSelectionFormula = "{V_XRRK_CROSSTAB.REPORT_RANK} <= 300"
        
    ElseIf strReport = "All" Then
        frmReport.Caption = "Hazard Rating For All Crossing's"
        Set Report = Application.OpenReport(App.Path & "\Database\Hazard Ratings.rpt")
        strSelectionFormula = "{V_XRRK_CROSSTAB.CROSSING_RANK} >= 0"
        
    ElseIf strReport = "Single Crossing" Then
        mfrmMain.stbMainStatusBar.SimpleText = "Build your report filter."
        frmReportQuery.LoadDefaultFields
        If Cancel = False And strSelectionFormula <> "" Then
            frmReport.Caption = "Crossing Report"
            Set Report = Application.OpenReport(App.Path & "\Database\Single Crossing.rpt")
        End If
        
    ElseIf strReport = "County" Then
        mfrmMain.stbMainStatusBar.SimpleText = "Select the County."
        frmCounty.LoadDefualtValues
        If Cancel = False And strCounty <> "" Then
            frmReport.Caption = "County Report"
            Set Report = Application.OpenReport(App.Path & "\Database\County.rpt")
            strSelectionFormula = "{V_XLOC_CROSSTAB.COUNTY} = '" & strCounty & "'"
        End If
        
    ElseIf strReport = "Accident" Then
        frmReport.Caption = "Accident Report"
        Set Report = Application.OpenReport(App.Path & "\Database\Accident.rpt")
        strSelectionFormula = "{V_ACCIDENTS_REPORT.RRXingNum} > '0'"
    End If
    
    mfrmMain.stbMainStatusBar.SimpleText = "Report being generated..."
    
    If Cancel = False And strSelectionFormula <> "" Then
        'Get report subtitle from user
        Report.ReportTitle = InputBox("Enter Report Subtitle: ", "Report Subtitle", "")
        'Set up report
        Report.Database.Verify
        CRViewer1.ReportSource = Report
        
        'Set the RecordSelectionFormula property of the report
        Report.RecordSelectionFormula = strSelectionFormula
                
        'View the report
        frmReport.Show
        CRViewer1.ViewReport
 
        'Set Paper Size and Orientation
        Report.PaperSize = crPaper11x17
        Report.PaperOrientation = crLandscape
    End If
    
    mfrmMain.stbMainStatusBar.SimpleText = ""
    Me.MousePointer = vbDefault
    Cancel = False
    Exit Sub
errhandler:
    Cancel = False
    strSelectionFormula = ""
    mfrmMain.stbMainStatusBar.SimpleText = ""
    Me.MousePointer = vbDefault
    MsgBox Err.Description, MSGBOX_ERROR, "Report Error"
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Joe Khoury
Joe Khoury

So what's the solution to this issue? I'm getting the same error when running the application through citrix in production. It works in our other environments.
You should ask a NEW question

mlmcc