Link to home
Start Free TrialLog in
Avatar of animated405
animated405

asked on

MS Reporting Services Currency Variable Type


Hello,

I've put a function in the report parameters code section where I want to set the value of some currency to 0.00 depending on the value from another field which has been passed in. It's wrapped inside a sum function in the expression so that only my revenues from product are calulated within the headers in each of my groups. Why can't I use the currency variable type inside of here? Next best thing is Double, but I'd rather show the exact amounts, plus i'd like to understand what's going on here. Here is there error I get when I try to use Currency:

There is an error on line 1 of custom code: [BC30389] 'System.Currency' is not accessible in this context because it is 'Private'.

Here is the function I'm trying to use, double works no problem but rounds it off

Public Function getDollarValue(ByVal Value As String, ByVal Dollar As Double) As Double
  Dim rtnVal As Double
      
  If Value = "Discount" Then
    rtnVal = 0.00
  ElseIf Value = "Freight" Then
    rtnVal = 0.00
  ElseIf Value = "Tax" Then
    rtnVal = 0.00
  Else
    rtnVal = Dollar
  End if

  Return rtnVal
End Function


thanks in advance
Avatar of simon_kirk
simon_kirk
Flag of United Kingdom of Great Britain and Northern Ireland image

Not sure on the error message, but couldn't you use an expression within the textbox to determine what value is displayed?

Something like:

=IIF(Fields!MYFIELD.Value="Discount",0,IIF(Fields!MYFIELD.Value="Freight",0,IIF(Fields!MYFIELD.Value="Tax",0,Fields!MYFIELD2.Value)))

Or you could use the SWITCH function (http://msdn.microsoft.com/libr­ary/en-us/vblr7/html/vafctswit­ch.asp )
Avatar of animated405
animated405

ASKER


I figured you could but I wasn't getting the syntax correct for multiple statements because I didn't think you could just put several iif's together like that. I'm going to give that a shot

thanks, that works for a field where the value is a number, but I'm getting this error when I try to do it with the currency

The value expression for the textbox ‘textbox16’ uses an aggregate function on data of varying data types.  Aggregate functions other than First, Last, Previous, Count, and CountDistinct can only aggregate data of a single data type.

my field is returned is money, why would it think that the rows contain varying data types?? I've tried changing the properties of the field in the report but to no avail
ASKER CERTIFIED SOLUTION
Avatar of simon_kirk
simon_kirk
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike McCracken
Thanks  animated405 for closing this question

mlmcc
Reporting Tools Page Editor