crystal parameter onlly updates first time using SetParameterValue

Posted on 2008-11-14
Last Modified: 2012-05-05
I am creating a heading for my crystal report in my application, then passing it to the crystal report using the setparametervalue method of the report object. In crystal, there is a parameter called 'Report_Heading' which does not allow multiple values. There is also a formula which picks this parameter up and displays it in the heading.

This works fine the first time the report displays. But when I refresh my dataset with different data and re-display the report, the heading fails to update. The data in the report is different, but the new value for the parameter is not displayed.

The attached code is in a subroutine called from page_load.

I have tried using a report.load statement, and a report.refresh, and I'm out of ideas. Can anyone help?
Private Sub Refresh_Report(ByVal command_text As String)

 ' (code here to populate dataset1 using sql based on dropdownlists)

  Dim headingString as string = "This Report Heading"

  Dim thisreport As New CrystalReport1


  ' Report_Heading is the name of the parameter in the crystal report...


  CrystalReportViewer1.ReportSource = thisreport

End Sub

Open in new window

Question by:Stewart_in_Atlanta
    LVL 5

    Expert Comment

    When you say this routine is called from page_load, and then when you 'refresh the dataset', are you calling this same routine again?  The only other thing I can think of is possibly set the report object to nothing and reload it each time.

    Author Comment

    Hi  JGBreeden,
    yes, I'm calling the same routine each time from page_load. What changes is the contents of the dropdowns and the sql that I use to generate the dataset.
    I've made the following change but I get the same result - can you take a look and let me know if this is what you meant? I have replaced:
                Dim thisreport As New CrystalReport1
                Dim thisreport As CrystalDecisions.CrystalReports.Engine.ReportDocument
                thisreport = Nothing
                thisreport = New CR_Customer_Listing
                Dim reportPath As String = Server.MapPath("CrystalReport1.rpt")

    Author Comment

    Is anyone able to help me with this? I am now desparate. I would have thought the ability to pass a parameter to a Crystal report on an page would be straight forward. Perhaps someone who does this regularly could share some sample code?

    LVL 5

    Accepted Solution

    Hi Stewart,

    Sorry I didn't get back, I didn't really know what else to suggest.  As I am looking at our .net code (which I didn't write, I'm better with Crystal than .net) I see that we are using a ParameterFields() object, and we are passing it to the viewer object, not the report object.  I must be a little brain dead at the moment, because that doesn't sound right to me, but here is a snippet of the code we use:

            Dim Rpt As ReportDocument
            Dim ParamFields As New ParameterFields()
            Rpt = GetReport(MyReport)

            Dim StartDateField As New ParameterField()
            Dim StartDate As New ParameterDiscreteValue()
            StartDateField.ParameterFieldName = "StartDate"
            StartDate.Value = MyStartDate

            crViewer.ParameterFieldInfo = ParamFields
            crViewer.ReportSource = Rpt


    Author Closing Comment

    fantastic, that works fine. One thing, in case anyone else is following this... the line Rpt = GetReport(MyReport) didn't work for me.
    I replaced:
            Dim Rpt As ReportDocument
            Rpt = GetReport(thisreport)
            Dim rpt As New CrystalReport1
    Thanks, I really appreciate the help.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Suggested Solutions

    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    761 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

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now