Crystal Reports Subreport Missing Parameter Values

We are in the process of moving our Crystal Reports reports off of the report server and running them within an ASP.NET web application (using the CrystalReportViewer control). I am able to run most of the reports without a problem. For the small subset of reports that have an embedded subreport, I am receiving a Missing Parameter Values error each time I click on the subreport link.

The code used to render the reports is as follows:

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Partial Public Class ViewReport
    Inherits System.Web.UI.Page

    Private reportInfo As ReportInfo

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If (Not IsPostBack) Then
            reportInfo = TryCast(Session("ReportInfo"), ReportInfo)
            If (Not reportInfo Is Nothing) Then
            End If
        End If

    End Sub

    Private Sub BindReportParameters(ByVal reportDoc As ReportDocument)

        'Set Parameter Values
        For Each param As ReportInfoParam In reportInfo.Parameters
            SetParameterValues(reportDoc, param.ParamName, param.ParamValues)

    End Sub

    Private Sub ShowReport()
        Dim reportPath As String = ConfigurationManager.AppSettings("ReportPath").ToString + reportInfo.ReportName
        Dim reportDoc As New ReportDocument


        viewer.ReportSource = reportDoc

    End Sub

    Private Sub SetParameterValues(ByVal reportDoc As ReportDocument, ByVal paramName As String, ByVal valueList As List(Of String))

        Dim paramValues As ParameterValues = New ParameterValues()

        For Each value As String In valueList
            Dim discreteValue As New ParameterDiscreteValue()
            discreteValue.Value = value

        Dim fieldDef As ParameterFieldDefinition = reportDoc.DataDefinition.ParameterFields(paramName)

    End Sub

End Class

Open in new window

The subreport that I am testing first has four parameters, three that are derived from the three parameters passed to the main report, and one that is based on the data on the main report record.

I have tried resetting the subreport links, removing the links and re-adding them, and am still unable to get the subreport to render.

Using Crystal Reports 10, VS 2008, SQL Server 2008

Any ideas?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CAn you link the subreport to the main report using the subreport parameters and values from the main report?

If not you have to do something like

For Each obj in ReportDoc
    If Obj,type = crSubReportObject then
       Pass parameters to the subreport
Next obj

Pass parameters to a subreport in a similar manner to the main report

I think since you manipulate the main report parameters and use main report data then the linking is the way to go.

wframsayAuthor Commented:
CAn you link the subreport to the main report using the subreport parameters and values from the main report?

Actually, that is what I have done already. There are three parameters that the main report gets, and those three plus a fourth based on one of the data elements in the main report detail rows is what is supposed to launch the subreport. I still get a "Missing Parameter Values" error.

I attempted to apply the parameters to the subreport programatically, but received the same error.
Can you upload the report?

Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

wframsayAuthor Commented:
Here is the rpt file for the report in question.
Can the UPC field be NULL?

if so you may have to deal with that.

Other than that I don't see any obvious issues.

wframsayAuthor Commented:
The UPC is always Not NULL - the primary report is a listing of summary information by UPC, so there should never be a situation where there is no UPC for the subreport.
wframsayAuthor Commented:
I have discovered the problem with the report viewer. What I needed to do was re-bind the parameters to the report on Postback, instead of only binding them when I initially displayed the report. Now it all works correctly.

Thank you for your assistance.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wframsayAuthor Commented:
I modified the subreport to accept only columns from the original report and still received the Missing Parameter Values error. Then I hardcoded the values, completely unlinking the two reports and still received the error.  Once I saw that, I knew that there was a problem with the way the main report was working, and tried commenting out the IsPostback() call, and the report and its subreports worked like a charm.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.