SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Development Tools
 Reporting Services Development
 Custom Code
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Basim
Starting Member

Bahrain
1 Posts

Posted - 01/14/2013 :  01:12:39  Show Profile  Reply with Quote
Hi,

Wrote a Custom Code i.e. a function.
Can not refer to this function from an expression area. It says unrecognized identifier.


Public dim pct_total as double
Public dim p_dept as string
Public dim p_rname as string
Public dim p_proj as string


Public function add_pct(byval dept as string,byval rname as string,byval proj as string,byval pct as double) as double

If p_dept <> dept or p_rname <> name or p_proj=proj then
pct_total=pct_total+pct
End If


p_proj=proj
p_dept=dept
p_rname=rname

return pct

End Function

Public function get_total_pct() as double
return pct_total
end function



=Code.add_pct(Fields!Departments.value,Fields!ResourceName.Value,Fields!ProjectName.Value,Fields.Percentage.Value)


=Code.get_total_pct()


Any thought please ?


James K
Flowing Fount of Yak Knowledge

3661 Posts

Posted - 01/14/2013 :  03:01:41  Show Profile  Reply with Quote
I don't see anything obviously wrong with your report that can cause that error to be generated - unless you are using a custom assembly and not referencing the custom assembly. Compare what is described on this MSDN page to see which of the two approaches you are using --> http://msdn.microsoft.com/en-us/library/ms156028.aspx

Another problem - although you have not run into it yet - is that if you are using SSRS 2008 or later global variables may not behave the way you expect them to. In 2008 and later, the order in which expressions are evaluated is not guaranteed. So the results you get may not be what you expect. A better option would be to use report variables or group variables if at all possible.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 01/14/2013 :  03:22:10  Show Profile  Reply with Quote
sorry didnt understand why you want to nest functions like this. Why not return total from first function itself?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000