I am trying to implement a function for my SSRS report which will return a color value depending on the values of three dates:
Function SetBoxColor(dateOne As Date, dateTwo As Date, dateThree As Date) As String
' Determine colors for text box
If (dateOne Is Nothing) Then
SetBoxColor = "Blue"
Else
If (dateThree Is Nothing) Then
If dateOne >= Date.Now Then
If DateDiff("d",dateOne,Date.Now) < 90
SetBoxColor = "Yellow"
Else
SetBoxColor = "White"
End If
Else
SetBoxColor = "Orange"
End If
Else
If dateThree <= dateOne Or (Month(dateThree) = Month(dateOne) And Year(dateThree) = Year(dateOne)) Then
SetBoxColor = "Green"
Else
SetBoxColor = "Red"
End If
End If
End If
Return SetBoxColor
End Function
The parameters passed to this function are nullable date (SQL Server date type) from my dataset and I call the function from a TextBox’s BackgroundColor property as:
=Code.SetBoxColor(Fields!dateOne.Value, Fields!dateTwo.Value, Fields!dateThree.Value)
Running the function as is returns the error:
‘Is’ requires operands that have reference types, but this operand has the value type ‘Date’.
Any help would be appreciated.
Have you tried
dateOne = Nothing?