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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing multiple value parameter to Crystal in VB

Status
Not open for further replies.

Elanger

Programmer
Jan 9, 2002
17
US
Using Crystal 8.5, VB6, and the RDC:
I have no problem passing regular parameters to the report via VB, but I'm not sure how to pass values to a multiple value parameter.

I need to pass an array of values to a parameter. The parameter is set up in my .rpt. Now what syntax do I use in VB to choose each element and set the value?

Crystal documentation refers to the SetNthDefaultValue method, but that one apparently also prompts the user. There doesn't seem to be an equivalent CurrentValue method (without the prompts).

Any help would be appreciated!
Thanks,
Elky Langer
 
Multiple values can be passed through the AddCurrentValue method of the ParameterFieldDefinition object.

For Example:

'crxRPT is the name of the report object.
'ParameterFields(1) references the first parameter in the ParameterFieldDefinitions collection.

'Enable multiple values for the parameter
crxRPT.ParameterFields(1).EnableMultipleValues = True

'Pass three separate parameters to the parameter field.
crxRPT.ParameterFields(1).AddCurrentValue "Canada"
crxRPT.ParameterFields(1).AddCurrentValue "USA"
crxRPT.ParameterFields(1).AddCurrentValue "UK"
 
Thanks, that worked fine. I didn't realize it was that simple!

Do you know if there's a way to check if a value has already been added to a parameter? The values I'm adding are in a database table and there may be duplicates. I don't mine leaving out the duplicates, but there's no easy way to filter them out. The best thing would be to be able to test for it before adding a new value. Is this possible?
(Otherwise, I get an error when a duplicate value is added.)

Thanks!
Elky Langer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top