none
SSRS: cannot use custom code in Lookup function RRS feed

  • Question

  • Dear,

    I want to use the name of textboxes in SSRS Expressions. In order to achieve this, I have added following custom code in the Report Properties:

    Public Function TextBoxName(ByVal meString As String) As String
     Dim s As Integer = 19
     Dim e As Integer = meString.IndexOf("_TextBoxExprHost") - 19
     TextBoxName = meString.Substring(s,e)
    End Function

    Now, if you want to retreive the name of a txtbox, just use following EXPR for the txtbox:

    =Code.TextBoxName(Me.ToString)

    This works fine, however, I want to use the above code in a lookup:

    =Lookup(Code.TextBoxName(Me.ToString),Fields!LabelName.Value,Fields!Label_I.Value, "dsetLabels").

    This is NOT working, while replacing the Code.TextBoxName(Me.ToString) by a real string is working. Eg.:

    =Lookup("lblPatient",Fields!LabelName.Value,Fields!Label_I.Value, "dsetLabels")  WORKS FINE ....

    Anyone any idea why the code cannot be used within the Lookup function ?

    Tuesday, November 19, 2019 10:39 AM

All replies

  • Hi Bart,

    I've tested that using one simple custom function which only provides a string as return value. This could work in the lookup function.

    My assumption is that to use _TextBoxExprHost has violated the rule:

    "Source, destination, and result expressions cannot include references to report or group variables."

    So the lookup function was not working.

    For detail you could read : remarks- SSRS Lookup

    Regards,

    Lukas


    MSDN Community Support Please remember to click Mark as Answer; the responses that resolved your issue, and to click Unmark as Answer if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 20, 2019 3:31 AM
  • Hi Lukas,

    Thank you for your reply.

    Any tips how I can solve the issue?

    Kind regards,

    Bart

    Wednesday, November 20, 2019 8:16 AM
  • Hi Bart,

    I've consider this issue for a while but did not get anything yet. As it is by design, we could hardly work around it.

    I guess you need to use other approach to achieve your goal.

    Regards,

    Lukas


    MSDN Community Support Please remember to click Mark as Answer; the responses that resolved your issue, and to click Unmark as Answer if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Friday, November 22, 2019 3:28 AM