Solved

CR10 / VB.NET : RefreshReport Keeps Asking for Parameter Entry

Posted on 2004-07-30
13
2,608 Views
Last Modified: 2008-01-09
Hi All,

I've created a custom toolbar for the Report Viewer and having difficulty with the RefreshReport option always asking to enter the parameters required for the report.

When i first load the report, it doesn't ask because i have added the values as discreet values, code as follows:

... ... ...
            ' Set Discreet value to the entered integer
            pdvStockLessThan.Value = txtLowStockVariable.Text

            ' Add Discreet Value to Value Collection
            pvCollection.Add(pdvStockLessThan)

            ' Apply Value Automatically to Report
            rptLowStock.DataDefinition.ParameterFields("StockLevel").ApplyCurrentValues(pvCollection)

            ' Clear Collection and prepare for next parameter if any
            pvCollection.Clear()

            ' Set the report source for the crystal reports
            ' viewer to the report instance.
            ReportViewer.ReportSource = rptLowStock

            ' Zoom viewer to fit to the whole page so the user can see the report
            ReportViewer.Zoom(100)

            ' Get Report Page Count
            PageCount = rptLowStock.FormatEngine.GetLastPageNumber(New CrystalDecisions.Shared.ReportPageRequestContext)
... ... ...

Report Loads fine with the correct value as stated in the text box's default entry.

The problem here is that when i click on the Refresh button which in turn calls the RefreshReport sub, it pops up asking to enter the parameter which in this case, is the StockLevel Parameter

The following is the code that i've currently got for the refresh button (which i have tried multiple commands with the code to try and solve this) but to no avail.

Current Refresh Button Code:

    Private Sub tbnShowRefresh_Activate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbnShowRefresh.Activate
        ' Clear Collection and prepare for next parameter if any
        pvCollection.Clear()

        ' Set Discreet value to the entered integer
        pdvStockLessThan.Value = txtLowStockVariable.Text

        ' Add Discreet Value to Value Collection
        pvCollection.Add(pdvStockLessThan)

        ' Apply Value Automatically to Report
        rptLowStock.DataDefinition.ParameterFields("StockLevel").ApplyCurrentValues(pvCollection)

        ReportViewer.ReportSource = rptLowStock
        ReportViewer.RefreshReport()
        UpdatePageNumber()
    End Sub

No matter what i try it keeps asking for the parameters... I cant seem to find something that'll help me avoid this

Anyone out there got an answer for me?

Many thanks in Advance

Ray.
0
Comment
Question by:RayFrangie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +3
13 Comments
 
LVL 10

Expert Comment

by:ebolek
ID: 11677528
o. why dont you hold the values when the user first enters it, and then put the same code to the
refresh reprort event,

 Set Discreet value to the entered integer
        pdvStockLessThan.Value = txtLowStockVariable.Text

        ' Add Discreet Value to Value Collection
        pvCollection.Add(pdvStockLessThan)

        ' Apply Value Automatically to Report
        rptLowStock.DataDefinition.ParameterFields("StockLevel").ApplyCurrentValues(pvCollection)
This wioll automatically set the values again, and wont ask you the prompt box.This is the nature of crystal reports. Hold the valuies and set them back gaain in the refresh event

Regards
Emre
0
 
LVL 1

Author Comment

by:RayFrangie
ID: 11677581
Hi ebolek,

The value in the textbox will be changed by the user at runtime, and on clicking the refresh button, i need it to refresh the report with the new parameters.

Unless i'm doing something wrong (which is where i need your help :-) ) it keeps popping up with the Enter Parameter Values Dialog Box.

Hope this adds more light at the end of the tunnel

Thanks in advance

Ray.
0
 
LVL 10

Expert Comment

by:ebolek
ID: 11677607
that is fine. Put the same code in the refresh event but dont clear the values collection. Restore the values that user enters to the text box and then set the values to it.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:RayFrangie
ID: 11677668
ebolek,

Just tried your advice... same thing

Here's the code of the updated refresh event, maybe this will help:

    Private Sub tbnShowRefresh_Activate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbnShowRefresh.Activate
        ' Set Discreet value to the entered integer
        pdvStockLessThan.Value = txtLowStockVariable.Text

        ' Add Discreet Value to Value Collection
        pvCollection.Add(pdvStockLessThan)

        ' Apply Value Automatically to Report
        rptLowStock.DataDefinition.ParameterFields("StockLevel").ApplyCurrentValues(pvCollection)

        ReportViewer.ReportSource = rptLowStock
        ReportViewer.RefreshReport()
        UpdatePageNumber()
    End Sub


Thanks in Advance.

Ray.
0
 
LVL 42

Expert Comment

by:frodoman
ID: 11677968
Ray,

Is the refresh button being clicked the one on the crystal viewer or is it your own form button?

frodoman
0
 
LVL 1

Author Comment

by:RayFrangie
ID: 11678005
Frodo,

Its my own one.... (The crystal toolbar looks like crap so i brought it to life a little :P ) The code in the above post is the code for the Refresh Button.

I'm using the RefreshReport Command to refresh the report.



Ray.
0
 
LVL 42

Expert Comment

by:frodoman
ID: 11678156
Ray,

Unfortunately as far as I know there's no simple way to do what you want.  I've been involved in some previous discussions and that's been the result every time (example: http://www.experts-exchange.com/Databases/Crystal_Reports/Q_20944952.html ).

The only way I've heard of someone working around this is to have their own refresh button fire off a process that saves the current parameter values, closes the form containing the CR viewer, then opens a new instance of the form and kicks off the "new report" process.  Basically instead of refreshing you completely close the report and start over with the saved parameter values.  Of course this assumes that you're using a subform for your viewer and it isn't in your application's main form.

This isn't a great solution of course, but it's the only one that I've heard of being used successfully.  

Good luck,

frodoman
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 11679612
I agree with frodoman.  The RefreshReportCommand is set to delete the parameters and prompt for new ones.

mlmcc
0
 
LVL 1

Author Comment

by:RayFrangie
ID: 11683052
Hi Guys,

I was looking into it last night and had a look at the members for the CrystalReportViewer as seen here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/crystlrf/html/crlrfwindowsformscrystalreportviewermemberstopic.asp

It seems like there's a ReportRefresh Event which should fire when the report is refreshed (Which in theory should fire when the CrystalReportViewer.RefreshReport. command is used). Any one tried using this event to do what i'm after? I havent tried it yet, i will later on though...

Any info is more than welcome

Many thanks

Ray.
0
 
LVL 13

Accepted Solution

by:
EwaldL earned 500 total points
ID: 11684121
the behaviour you see with the RefreshReport method is by design.  msdn describes if functionality as follows on
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/crystlrf/html/crlrfwindowsformscrystalreportviewerclassrefreshreportmethodtopic.asp

"This method will refresh the data for the report currently displayed in the viewer. Any parameters or logon information, needed by the report, will be prompted for."

So instead I would try to refresh the report itself (not the viewer), pass the parameters to it and then pass the report to the viewer.

something like this

rptLowStock.Refresh()
rptLowStock.SetParameterValue("StockLevel", "YourValue")
ReportViewer.ReportSource = rptLowStock
0
 
LVL 1

Author Comment

by:RayFrangie
ID: 11684762
EwaldL,

Perfect... Exactly what i wanted...

Loads the report perfectly, does not ask for a parameter, you hit the nail on the head. 500 Points to you.

Many thanks to all, hope you all learnt something new just like i did

Once again, many thanks

Regards,

Ray.
0
 
LVL 13

Expert Comment

by:EwaldL
ID: 11684991
nice one, good to hear it's working for you now! :-)
0
 

Expert Comment

by:joshsteiner
ID: 11907626
the problem with EwaldL's solution (which is what i did first) is that assigning a new reportsource to a viewer seems to tear down the whole widget and spawn a new on (behind the scenes, watch with your debugger)... ie: its painfully slow and has some nasty flash as it destroys the existing widget.  whereas if you use the viewers refresh button/method, its much quicker and slicker.  i have 6 charts embeded in my app, and hence the slowness is multiplied by 6, so i really need to find a way to set the parameter in the current existing report in the viewer... any hope?

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

763 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