cancel
Showing results for 
Search instead for 
Did you mean: 

Custom ParameterPromp form

Former Member
0 Kudos

I wish to create my own window where I can prompt for parameter values BEFORE the report is run. I need these parameter values as I supply the Crystal Report with data based on those parameters. The Crystal Report doesn't interact with the database directly.

Is there a way for me to obtain the values of the enetered parameters before the report is run and before I set ReportDocument.SetDataSource(thedatasource)?

If not, how can I easily create a dynamic form which will prompt the user for paramaters? I noted the following control CrystalDecisions.Windows.Forms.ParameterPromptControl but I couldn't find any information about the control on the Internet.

Your help is creatly appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Not sure what you are doing with the parameters but typically you add the parameters to the report itself. Then when you run the report Crystal will prompt you to enter the parameters or you can add them in code using the CR Parameter API's.

If you want the filtering done outside of Crystal then there are various ways to get the parameter values, filter the record set and set the report DB location to that data source. How you prompt for the values is outside of CR at this point so you simply need to create your own Parameter form, save the values and apply them to your data set. Once this is done then CR uses your final filtered data.

Bascially what you want to do is design the report first and a simple CR rule to remember: "If you can't do it in the designer you can't do it in code" CR developer uses the same but limited set of API's as the Designer.

If you need assistance creating the report with Crystal Parameters post your question to the Report design forum.

Former Member
0 Kudos

Thanks for the reply. When I add parameters in the report, then Crystal prompts for the values when the report is run, right? Is there a way in which I can use the paramers prompt window of Crystal(so I don't need to write my own one) and still filter the data outsite the report and then just set the report's datasource to the filtered data?

Due to design constraints and how the data are accessed(through remoting(tcp & ipc), local datasets and database connections) we cannot design a static parameter prompt box before runtime. (We've got a report designer(person excellent in report design, but almost no programming skills) that designs reports and he just need to copy the .rpt file into a directory and which ever parameters he specified in the report we need to access before the data are given to the report. The parameters prompt window of Crystal is excellent as it evaluates the parameters, see what their types(range value, discrete or both, number, date, time, etc.) are and create the appropriate prompt controls for the user to intput. The prompt window of Crystal already does all the work for me, I just need to get those parameter values before Crystal tries to retrieve data with them.

Is there an easy way to do this, or is the best way to create my own parameter prompt window at runtime? I also noted the CrystalDecisions.Windows.Forms.ParameterPromptControl class, but I couldn't find any information about the classed contained within it. Is there any way where I can find out more about this class and what it's function is? I now it's a UserControl

0 Kudos

Hi JD,

Just to be clear, the CR parameter prompt will only appear if the report uses paraemters within. You can not use it for anything else outside of CR SDK.

What you want to do is create your Parameter prompt to filter the data on the front end and then pass this to CR Designer. Then you want to discuss this with your Report Designer saying you are passing the filtered data and to remove any CR parameters from the report.

I hope htis is clearer. If not, discuss this with your Report Designer, I'm sure that person understands how the report and paraemters work.

Thank you

Don

Former Member
0 Kudos

I think I've done what you are talking about. Here is what I do: I loop through the ParameterFieldDefinition collection and get a reference to each ParameterFieldDefinition object. Get the properties of each one to create a dynamic form that prompts the user for the current value. Then call the SetParameterValue() method of the ReportDocument object to put the user's input into the report parameters prior to running the report. Takes a little bit of coding, but nothing too bad after you build the initial loop.

I have the parameter and formula classes documented in Chapter 16 of my CR.NET 2005/2008 book that I just published. I also document the entire report object model if you are interested in doing more runtime report modifications. You can find it on Amazon if interested.

former_member208657
Active Contributor
0 Kudos

I had a look at the ParameterPromptControl. Although it is a public class it isn't meant for consumers to use directly. We don't have any documentation on it and it doesn't appear to work unless you have a CrystalReportViewer to go along with it.

Go with Don's suggestion and build your own prompting dialog. You'll want to use the ReportDocument.ParameterFields collection to get a list of your parameters to fill in the dialog.

Former Member
0 Kudos

I actually though of doing it the way you described below, but I thought there would be an easier way to do this. The parameter prompt window created by CR at runtime already implements all the available settings for the different parameter types.

For example. When I say I want string values, but it should allow multiple values, then I can run the report and the parameters are prompted in the appropriate manner. Now I need to check in code whether the parameter allows multiple values, and I need to make provision for that in the parameter prompt controls I'm adding at runtime.

So just to make everything clear again. There's no way where I can run the report and use the parameter boxes/window created by CR before I retrieve the data and set the datasource of the report with the data filtered based on values entered in the CR parameter box prompts?

Former Member
0 Kudos

David: I noted the following properties and methods on the ParameterPromptControl control. ParameterFieldsToPrompt and StartPromting() and SubmitForm(). Is there any way in which I can rather use this class than dynamically adding and determining which type of parameter(boolean(ComboBox), string(TextBox), date(DateTimePicker), time) to prompt for at run-time? What makes it even more difficult is the different settings a parameter can have. Settings such as allow multiple, default values etc. makes coding a custom prompt box much more difficult and tedious.

I just don't want to put all this effort into coding a properly working parameter prompt box if there already exist classes that can assist me in doing this. If there's no other way, I'll just code it then.

Thanks for the help.

former_member208657
Active Contributor
0 Kudos

I already went down the avenue of using the StartPrompting() method. It always returned "object or reference not set to an instance of an object". I had a good look at this for over and hour and couldn't figure it out. There is no documentation on this because it isn't meant for public consumption.

It looks like you are out of luck. Sorry.

Answers (0)