Visual Studio 2019, Crystal Reports 14, Sub Report, Incorrect Paramater RRS feed

  • Question

  • Hi,

    I created a report with one sub report in it. When I preview the report in Crystal Reports, all is working perfect.

    The moment I fire the report from my VB code to preview the report in CRViewer, I am getting a message "The paramater is incorrect". My sub report is linked to the main report and If I preview in crystal all is fine, included the data.

    glbReport = App_Path() & "Reports\Pick.rpt"
    glbFmlaText = "{picklist.cpnyid} = '" & glbCpnyId & "' and {picklist.pastelref} = '" & sKey & "' "
    report.Load(glbReport, CrystalDecisions.Shared.OpenReportMethod.OpenReportByDefault)
    frmReport.ViewReport(glbReport, glbFmlaText, "")

     Friend Function ViewReport(ByVal sReportName As String, Optional ByVal sSelectionFormula As String = "", Optional ByVal param As String = "") As Boolean
            Dim intCounter As Integer
            Dim intCounter1 As Integer
            Dim objReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            Dim paraValue As New CrystalDecisions.Shared.ParameterDiscreteValue
            Dim currValue As CrystalDecisions.Shared.ParameterValues
            Dim mySubReportObject As CrystalDecisions.CrystalReports.Engine.SubreportObject
            Dim mySubRepDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            Dim strParValPair() As String
            Dim strVal() As String
            Dim index As Integer
            CrConn = New CrystalDecisions.Shared.ConnectionInfo
            CrConn.ServerName = sServer
            CrConn.DatabaseName = sDatabase
            CrConn.IntegratedSecurity = True
            ConInfo = New CrystalDecisions.Shared.TableLogOnInfo
            ConInfo.ConnectionInfo = CrConn
                'Load the report
                objReport.Load(sReportName, CrystalDecisions.Shared.OpenReportMethod.OpenReportByDefault)
                intCounter = objReport.DataDefinition.ParameterFields.Count
                If intCounter > 0 Then
                    'to see id date selection was made
                    Dim parFields As New CrystalDecisions.Shared.ParameterFields
                    Dim parField As New CrystalDecisions.Shared.ParameterField
                    Dim parRange As New CrystalDecisions.Shared.ParameterDiscreteValue
                    parField.ParameterFieldName = "ReportDates" ' Parameter Name In Crystal Report
                    parRange.Value = glbFormula ' value For Parameter Field 
                    parFields.Add(parField) ' To add parameter in parameterslist
                    crViewer.ParameterFieldInfo = parFields
                End If
                If intCounter = 1 Then
                    If InStr(objReport.DataDefinition.ParameterFields(0).ParameterFieldName, ".", CompareMethod.Text) > 0 Then
                        intCounter = 0
                    End If
                End If
                If intCounter > 0 And Trim(param) <> "" Then
                    strParValPair = param.Split("&")
                    For index = 0 To UBound(strParValPair)
                        If InStr(strParValPair(index), "=") > 0 Then
                            strVal = strParValPair(index).Split("=")
                            paraValue.Value = strVal(1)
                            currValue = objReport.DataDefinition.ParameterFields(strVal(0)).CurrentValues
                        End If
                End If
                For intCounter = 0 To objReport.Database.Tables.Count - 1
                For index = 0 To objReport.ReportDefinition.Sections.Count - 1
                    For intCounter = 0 To objReport.ReportDefinition.Sections(index).ReportObjects.Count - 1
                        With objReport.ReportDefinition.Sections(index)
                            If .ReportObjects(intCounter).Kind = CrystalDecisions.Shared.ReportObjectKind.SubreportObject Then
                                mySubReportObject = CType(.ReportObjects(intCounter), CrystalDecisions.CrystalReports.Engine.SubreportObject)
                                mySubRepDoc = mySubReportObject.OpenSubreport(mySubReportObject.SubreportName)
                                For intCounter1 = 0 To mySubRepDoc.Database.Tables.Count - 1
                            End If
                        End With
                If sSelectionFormula.Length > 0 Then
                    objReport.RecordSelectionFormula = sSelectionFormula
                End If
                crViewer.ReportSource = Nothing
                'Set the current report object to report.
                crViewer.ReportSource = objReport
                'Show the report
                Return True
            Catch ex As System.Exception
            End Try
        End Function

    Always try something new....dont walk in the shoes of the dead.

    Tuesday, September 17, 2019 12:57 PM

All replies

  • Hi SoftSpot,

    Welcome to the MSDN forum.

    According to your description, your issue is more related to Crystal Reports for Visual Studio,so please redirect your issue to the SAP Crystal Reports for Visual Studio forum for better support since our forum discuss about the use of VS IDE and editor. The forum staff will receive and troubleshoot your issue as soon as possible.

    Thanks for your understanding.

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Wednesday, September 18, 2019 7:24 AM
  • Thanks

    Always try something new....dont walk in the shoes of the dead.

    Wednesday, September 18, 2019 8:15 AM