views:

617

answers:

2

I'm trying to make use of the custom code feature within SSRS (SQL Server Reporting Services), but keep getting an "Unrecognized identifier" message in the Expression Editor.

Here's my custom code. Actually, the final routine will be more complicated than this, but I'm trying to simplify things to figure out why the error is happening.

Public Function GetCutoffDate(batchNumber As String) As DateTime
    Return New DateTime(Now.Year, 12, 31)
End Function

Here's how I reference the code in the Expression Editor.

=IIf(UCase(Fields!MailId.Value) = "VARIOUS", 
 Code.GetCutoffDate(Fields!BatchNumber.Value), 
 Fields!CutOffDate.Value)

I'm getting a red underline under the "GetCutoffDate" portion of Code.GetCutoffDate(..). Also, the message "Unrecognized identifier" appears when I hover my mouse over the "GetCutoffDate" text.

What am I missing?

I've also tried the following in the Expression Editor but keep getting the same "Unrecognized identifier" message.

=Code.GetCutoffDate(Fiels!BatchNumber.Value)

I must be overlooking something, but can't see what it is.

Thanks.

A: 

Try

Public Shared Function GetCutoffDate(batchNumber As String) As DateTime ...

in the function declaration, which has worked for me.

Ed Harper
A: 

Turns out my custom code would still work, despite getting the "Unrecognized identifier" message. I was getting confused because the dataset I had specified was return back zero records.

Still not sure why the "Unrecognized identifier" message comes up, though. Very annoying.