Solved

Refresh Crystal Report after Print taken

Posted on 2011-03-03
5
636 Views
Last Modified: 2012-05-11
hi,

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!
View-Code.txt
Print-Code.txt
0
Comment
Question by:meispisces
  • 2
5 Comments
 
LVL 100

Expert Comment

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

mlmcc
0
 
LVL 7

Author Comment

by:meispisces
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.
0
 
LVL 18

Accepted Solution

by:
UnifiedIS earned 500 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
            rptPersistent.Load(_ReportPath)
            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)
                                PVS2.Add(PV)
                            Next
                        End If
                    Next
                Next
                rptTemp.Close()
                rptTemp.Dispose()
            End If
0
 
LVL 100

Expert Comment

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
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…

809 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