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
 Ref. ds members from w/i custom code

Author  Topic 

incurablygeek
Starting Member

1 Post

Posted - 2008-04-30 : 13:34:03
I've got a function in custom code called for every line in a table that uses a case statement to return various values. In some cases, a calculation is required. In other cases, a return of a value from another dataset is all that's necessary.

Assuming the function is called from a field in a table linked to Dataset B, is there a way to reference a member of Datset A from within the code?

With the simplified function below (calculations are omitted for brevity), I get a build error "Reference to a non-shared member requires an object reference. I'm trying to figure out how to express the object reference (if possible). I would need, in some case, to reference members of another dataset for performing calculations.

I could probably do all this in a stored procedure but I'm figuring out what's do-able within custom code.

Example:
Public Function GetValueForLine(RowName as String) as String
Select Case LCase(RowName)

Case "start date"
Return Fields!RptHdrData.start_date.Value

Case "end date"
Return Fields!RptHdrData.end_date.Value

Case "currency"
Return Fields!RptHdrData.currency_code.Value

Case Else
Return "Unknown"
End Select
End Function

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-02 : 14:01:08
I dont think you can access your fields like this inside custom code.The fields will not be directly available inside custom code however you can pass the field collection as parameters to function and access their individual values inside.Similarly parameters collection can also be passed inside custom code.


ex:
Public Function GetValueForLine(RowName as String,retfields As Fields) as String
Select Case LCase(RowName)

Case "start date"
Return retfields!RptHdrData.start_date.Value

Case "end date"
Return retfields!RptHdrData.end_date.Value

Case "currency"
Return retfields!RptHdrData.currency_code.Value

Case Else
Return "Unknown"
End Select
End Function
Go to Top of Page
   

- Advertisement -