Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 Custom Function to generate tag content

Author  Topic 

jabin
Starting Member

3 Posts

Posted - 2007-05-24 : 11:51:13
I have a report where I would like to use a custom function to generate the appropriate content to go between the <value> and </value> tags. Currently I have code like the following:<Value>=IIF(Parameters!FldName1.Value="AccountNumber", Fields!AccountNumber.Value, (IIF(Parameters!FldName1.Value="Application", Fields!Application.Value, ......for 30 different fields to select from for each of 15 columns. This works well and ends in with <value>=Fields!Account.Value</value> which selects the results from that field from the returned dataset to display n the report. I'd like to have one custom function that I could call to replace all this repeated code in my RDL. This could save a lot of lines of duplicated code. I've tried using <Value>=Code.SelectField(Parameters!SortBy.Value) </Value> where the SortBy value is the users selection from a drop down list of possibilities. I'm passing this to my custom function,
Shared Function SelectField(ByVal SelField As String)
Dim ThisField
Select Case SelField
Case "AccountNumber"
ThisField = "=Fields!AccountNumber.Value"
Case "Application"
ThisField = "Fields!Application.Value"
.......etc for all the possibilities followed by Return ThisField.

What gets returned between the <value>..</value> tags is a literal string that is then simply reproduced on my report verbatim. That is no data from the actual dataset appears, just the text between quotes (e.g. AccountNumber). If I remove the quotes I get an error when building and trying to deploy the report (Reference to a non-shared member requires an object reference). Any insite on how to do this would be greatly appreciated. Thanks, Jim.
   

- Advertisement -