How to refer Variable in Custom Code
HI - I have defined variable from Report properties in SSRS BIDS. How can I refer that variable in custom Code written in VB. Please advise me
May 31st, 2012 7:04am

Hi, You can create a variable by access the Report Properties->variables link. (say ThisValue with default value) and then access the varaible in the VB script function like below Public Function CalcMedTotal(ThisValue as Integer) as Integer Return ThisValue End Function You can call this fuction from the report expression Eg..Code.CalcMedTotal(2000)..Which return 2000 for this example.
Free Windows Admin Tool Kit Click here and download it now
May 31st, 2012 7:20am

Thanks for reply. But my requirement is something different. I have difened variable V1 and assigned some value per say 10 Now, how can I used this V1=10 in custom code Public Function CalcMedTotal() as Integer <<how can I use V1 here>> Return V1 End Function
May 31st, 2012 7:36am

As you said i declared a variable V1 with default value 100 and using in my function and returning the result...hope this will help u.. Public Function CalcMedTotal(v1 as Integer) Dim Result AS Integer Result=v1+100 Return Result End Function
Free Windows Admin Tool Kit Click here and download it now
May 31st, 2012 9:25am

dont pass the variable to funciton. Try to refer it without passing it. The reason for this requirement is using the global variables in Group expression is not allowed. That is why i am looking for a way to directly refer the variables in function.
May 31st, 2012 9:36am

You can create custom function & pass SSRS Variables to your code as below expression =Code.YourFunction(Variables!YourVariable.Value) And then do implement your business logic in your custom code. Hope this helps. Thanks, Sandip Shinde(Blog:bi-bigdata.com|Twitter:@CloudBI_Sandip)
Free Windows Admin Tool Kit Click here and download it now
May 31st, 2012 10:56am

I want to call this function from Group Expression and at group level it is not allowing to pass the Variables(throwing error). That is why i would like to check whether I can directly refer the global variable in custom function without passing from somewhere.
May 31st, 2012 11:17am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics