Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The value or range you are adding has already existed.

Status
Not open for further replies.

N11689

Programmer
Jan 29, 2002
113
US
Running a report in Crystal XI through our VB application. The only change made was to Set Datasource to a different database. Report is based off a stored procedure. The stored procedure has not changed. Can run the report fine from within Crystal, but suddenly the VB program errors with this message.

Please help...haven't found anything on any websites to correct this.
 
Are you setting the parameter values in your code at runtime, or are you showing the default Crystal parameter values window?

I can make that error happen if I call the AddCurrentValue method for a parameter field, and try to set the same parameter value both times.

I can also make it happen if I've got a multiple value parameter, and the value has already been added:
Code:
Report.ParameterFields.Item(1).AddCurrentValue "a" [green]'Ok[/green]
Report.ParameterFields.Item(1).AddCurrentValue "b" [green]'Ok[/green]
Report.ParameterFields.Item(1).AddCurrentValue "a" [red]'ERROR[/red]
Since stored procedure parameters don't allow multiple values or range parameters, the only thing I can suggest you check is anywhere you're calling the AddCurrentValue method, make sure the same value isn't getting added again.

-dave
 
Thank you for the help.
The situation we found is similar to what you describe.
We get the error message when we try to use AddCurrentValue and the value we are adding is equal to the value for that parameter last entered in Crystal Reports Developer when we executed a Set Datasource Location. It is as though the Crystal RDC is telling us the parameter is already set to that value (as you have shown with your example above).
Example:
We open a report with one input parameter in Crystal Reports Developer. We select Set Datasource Location to change the datasource. When prompted for a value for the input parameter, we enter "N". We save the .rpt.
At runtime, we use RDC to execute the report. We use the AddCurrentValue method to set the parameter, like so:
Report.ParameterFields.Item(1).AddCurrentValue "A"
That works fine.
If the parameter is "N" (equal to what was used when setting the datasource) like so:
Report.ParameterFields.Item(1).AddCurrentValue "N"
that is when we get the error.
We have made a change to enable multiple values before adding the parameter value.
So our code now looks like:
Report.ParameterFields.Item(1).EnableMultipleValues
Report.ParameterFields.Item(1).AddCurrentValue "N"
This works even if the value we are trying to set is the same as the value used when setting datasource (in the example above, "N").
Not sure what other issues this may cause, but for now it is working.
Thought you might be interested in our solution.
Again, thank you for the help.
 
You might try using the ClearCurrentValueAndRange method before adding values.

-dave
 
The first thing we tried was ClearCurrentValueAndRange, and that did not help.

Thanks for the continued help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top