all groups > sql server reporting services > june 2006 >
You're in the

sql server reporting services

group:

Pass parameter & Field to a Function


Pass parameter & Field to a Function BillB
6/27/2006 8:47:02 AM
sql server reporting services:
Hi
Can anybody help with this? Using RS2005.

Question 1: What's the proper syntax for the expression to pass
a parameter and a field (.value) to my Function.

Question 2: I get an error caused by business_source that says, report item
expressions can only refer to fields within the current data scope.
What does this mean (business_source) is in my select statement
on the "Data" tab???
Given:
Environment is set up as a parameter with 2 valid entries.



=Code.Get_Remit_To_Name(@Environment,
Fields!Business_Source.Value)

=Code.Get_Remit_To_Name(Parameter!Environment.Value,Fields!Business_Source.Value)

Question 3: Is one of the above correct or are they both wrong?


Function Get_Remit_To_Name(ByVal ValueEnv as String, ByVal ValueSrc as
String) As String
If ValueEnv = "abcde"
If ValueSrc = "Contract"
return "Company Name AA"
ELSE
return "Company Name BB"
End If
ELSE
return "Company Name CC"
End If
End Function

Any help will be much appreciated. Been Hackin at this for some time now!
Re: Pass parameter & Field to a Function will.s.smith NO[at]SPAM gmail.com
6/27/2006 11:49:20 AM
Can't promise to get all of your points covered, but I'll try:

Proper syntax to call the function in your situation would be:

(in a table or textbox linked to a dataset)
=Code.Get_Remit_To_Name(Parameters!Environment.Value,
Fields!Business_Source.Value)

-Or-

(in a textbox not linked to a dataset)
=Code.Get_Remit_To_Name(Parameters!Environment.Value,
First(Fields!Business_Source.Value, "business_source"))

So, depending on where the expression lives, you'll have to access the
field differently.

I think that should solve all of your problems actually.
Re: Pass parameter & Field to a Function will.s.smith NO[at]SPAM gmail.com
6/27/2006 11:52:10 AM
EDIT: Need to correct the 2nd example. Should be:

(in a textbox not linked to a dataset)
=Code.Get_Remit_To_Name(Parameters!Environment.Value,
First(Fields!Business_Source.Value, "DataSet1"))

I was under the impression that "Business_Source" was the name of your
dataset. So now, just replace "DataSet1" with whatever your dataset
name is.
AddThis Social Bookmark Button