Refresh Crystal Report after Print taken

Posted on 2011-03-03
Medium Priority
Last Modified: 2012-05-11

I have one report developed in .net application. Now say a user views the report and wish to print that report. hence for printing we have used our own Print Button and not the Crystal Report viewer default print button as we need to store the print date in database (which is today's date).

Said that, now when the print button is clicked, i wish the report to be refresh. I have tried Crystal Report.Refresh and ReportRefresh. The refresh does nothing while report refresh does refresh BUT it asks for the parameter (prompt for all the parameters in the report)

hence, what should i do in this case?

I have attached my code for View button and print button.

Kindly have a look as to get an idea of how view and print works.

Thanks much!
Question by:meispisces
  • 2
LVL 101

Expert Comment

ID: 35031394
WHy do you feel the need to refresh the report?

Printing it will use the existing parameters and run the report with current data assuming you don't have saved data.

Refresh causes the report to discard the parameters and want new ones.


Author Comment

ID: 35033796
@mlmcc: Because once the report is printed out, the report should become blank (showing no data in it). By blank, doesn't mean that the database should be cleared off.
LVL 18

Accepted Solution

UnifiedIS earned 2000 total points
ID: 35038120
A method to handle this is to cache the parameters.  Then you reload and reapply the saved parameters.

Here's a piece of some code that does this:
crv is my crystalreportviewer control
I use a class called ParameterValuePairs that houses the parameter name and value.

rptPersistent = New CrystalDecisions.CrystalReports.Engine.ReportDocument
            If Not Me.crv.ReportSource Is Nothing Then
                Dim rptTemp As CrystalDecisions.CrystalReports.Engine.ReportDocument = crv.ReportSource
                Dim PVP As ParameterValuePairs
                Dim PVS As CrystalDecisions.Shared.ParameterValues
                Dim PV As CrystalDecisions.Shared.ParameterValue
                Dim PVS2 As CrystalDecisions.Shared.ParameterValues
                arParameterValues = New ArrayList
                For Each pf As CrystalDecisions.Shared.ParameterField In rptTemp.ParameterFields
                    PVS = pf.CurrentValues
                    For Each pf2 As CrystalDecisions.Shared.ParameterField In rptPersistent.ParameterFields
                        If pf2.Name = pf.Name Then
                            PVS2 = pf2.CurrentValues
                            For Each PV In PVS
                                PVP = New ParameterValuePairs(pf.Name, PV)
                        End If
            End If
LVL 101

Expert Comment

ID: 35275389
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Watch the video to know how one can repair corrupt Exchange OST file effortlessly and convert OST emails to MS Outlook PST file format by using Kernel for OST to PST converter tool. It can convert OST to MSG, MBOX, EML to access them. It can migrate…
When you have multiple client accounts to manage, it often feels like there aren’t enough hours in the day. With too many applications to juggle, you can’t focus on your clients, much less your growing to-do list. But that doesn’t have to be the cas…

624 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