Link to home
Start Free TrialLog in
Avatar of Roberto Madro R.
Roberto Madro R.Flag for United States of America

asked on

Crystal Report Parameter Values

I have a crystal report that I need to pass the values to its parameter programmatically, what's the best / most-optimal way to do that?
Thx
Avatar of Mike McCracken
Mike McCracken

I don't think there is really a "best" way to do that.

The best way to handle this, in my opinion, is to build the report to use a dataset and have the application open the dataset and pass the data to the report.  This is known as the push method.

If you pass the parameters to the report it is using the pull method which has many more pitfalls.

Here is an example of using the push method
http://www.emoreau.com/Entries/Articles/2006/09/Feeding-Crystal-Reports-from-your-application.aspx

If you need to pass the parameters
What version of Crystal?
What method are you using to open the report?
What language are you using for the application?

Perhaps the easiest method is to just call the report and let Crystal prompt using the default parameter screen

mlmcc
Avatar of Roberto Madro R.

ASKER

Great to hear from you mlmcc, I'm using Crystal 11.5 and I publish these reports to a crystal report server and they're accessed by users via our intranet (website-like access), as for what application I need to embed this report in, I can do asp or c#, but I need to know how to embed an existing report and supply its parameter with values when it's run or is scheduled to run.

Thanks for the link as well, (although old) a very interesting walkthrough.
Even though it is a bit old, it is still accurate on how to do it.

If you are publishing through CR Server why the need for an application?

mlmcc
I'm exploring what CR Server offers in that regard, I'll write you back on what I find.
On the CR Server, under the "Process" tab, you have the option to set a DEFINED VALUE for the parameters, from there, every time the report runs it'll take these values into account, but the issue is, and in my case here, the parameters I have are date parameters and I need to supply them with dates, example (currentdate -5 to currentdate -1), something like that.
Unfortunately, as far as I know, you can't do that.  I know with the BOE product you can't.  CR Server is a scaled down version of it.

We got around that issue by coding those kind of date ranges into the report.

If you want flexibility to use a range like that by default and also allow the user to input a range of their own you could set the default value for the dates to be 1/1/1900 then test for that value in the selection.

Something like

If {?StartDate} = Date(1900,1,1) then
    {DateField} >= CurrentDate - 5  AND {DateField} <= CurrentDate -1
Else
    {DateField} >= {?StartDate} and {DateField} <= {?EndDate}

mlmcc
Have you ever called a Crystal Report from command line? and if so, were you able to supply its parameters?
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great tools and resources website, and although I know Ken Hamady, the links you provided were of great help. The request for automating that report has changed, but the fact that I'm aware of this resource now is great.