Solved

Crystal Reports Subreport Missing Parameter Values

Posted on 2012-04-05
8
1,842 Views
Last Modified: 2012-04-17
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
                ShowReport()
            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)
        Next

    End Sub

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

        BindReportParameters(reportDoc)

        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
            paramValues.Add(discreteValue)
        Next

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

    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?
0
Comment
Question by:wframsay
  • 5
  • 3
8 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 37814717
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.

mlmcc
0
 
LVL 1

Author Comment

by:wframsay
ID: 37815883
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.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 37818161
Can you upload the report?

mlmcc
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 1

Author Comment

by:wframsay
ID: 37827515
Here is the rpt file for the report in question.
ShrinkSummaryByUPC-ZeroScan-sqls.rpt
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 37828974
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.

mlmcc
0
 
LVL 1

Author Comment

by:wframsay
ID: 37829030
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.
0
 
LVL 1

Accepted Solution

by:
wframsay earned 0 total points
ID: 37838974
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.
0
 
LVL 1

Author Closing Comment

by:wframsay
ID: 37854961
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.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question