Thursday, March 22, 2012

Error in using Multi varied parameters!

Hi,

I am tired of troubleshooting this. If I use sa MVP called say states and on the top of the page write

Parameters!orgstate.Value

I get the faSadmiliar "#Error" message. This works fine for any other parameter except MVP.? Anything that i am forgetting to do?

Let me know ASAP if anyone has an idea about this.

Thanks

Because it is a multi-value parameter you are getting back an array of values. You need to do something like:

Parameters!orgstate.Value(0)

-Daniel

|||

Once you mark a parameter as "multi-value", the .Value property will return an object[] with all selected values. If only one value is selected, it will be an object array of length = 1. Object arrays cannot be directly compared with Strings.

To access individual values of a multi value parameter you can use expressions like this:
=Parameters!MVP1.IsMultiValue
boolean flag - tells if a parameter is defined as multi value
=Parameters!MVP1.Count
returns the number of values in the array
=Parameters!MVP1.Value(0)
returns the first selected value
=Join(Parameters!MVP1.Value)
creates a space separated list of values
=Join(Parameters!MVP1.Value, ", ")
creates a comma separated list of values
=Split("a b c", " ")
to create a multi value object array from a string (this can be used e.g. for drillthrough parameters, subreports, or query parameters)

See also MSDN:
* http://msdn.microsoft.com/library/en-us/vblr7/html/vafctjoin.asp
* http://msdn.microsoft.com/library/en-us/vbenlr98/html/vafctsplit.asp

-- Robert

|||

Thanks Daniel!

No comments:

Post a Comment