May 20, 2011 at 10:50 am
Hi all,
We have a report that allows user to input the month. We do not want the user to select junk months, we would like them to select a month that is within min and max month ranges. I created min and max month datasets. Any ideas on creating a custom code that allows the user to select only the months with min and max ranges? Thanks in advance.
May 20, 2011 at 1:45 pm
I used the following for the above requirement but it gives this error when I run the report : The DefaultValue expression for the report parameter ‘Month’ contains an error: Month must be higher than MAR 2011 (rsRuntimeErrorInExpression)
Here is the code:
Public Function CheckMonth(minMonth as string, maxMonth as string) as string
CheckMonth = maxMonth.ToString()
End Function
Public Function CheckStartMonth(Month as string, minMonth as string, maxMonth as string) as string
Dim strMsg as string
strMsg = ""
If ( Month < minMonth ) Then
strMsg = "Month must be higher than " & minMonth.ToString
Else If (Month > maxMonth) Then
strMsg = "Month must be lesser than " & maxMonth.ToString
End If
If strMsg <> ""
Err.Raise(1, "Invalid Parameter", strMsg)
End If
Return "[Time].[Month].&[" & Month.ToString & "]"
End Function
Public Function GetStartMonth(maxMonth as String, minMonth as String) as String
Dim dtstartMonth as String
dtstartMonth = DateAdd("M", -1, maxMonth)
If minMonth = maxMonth Then
Return minMonth
Else If dtstartMonth >= minMonth Then
Return maxMonth
End If
Return dtstartMonth
End Function
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply