I am not certain why this vba code is producing a type mismatch...
I am writing a function that will calculate the estimated hours to complete (ETC) based on fields on a report. The function works through and selects the correct case, but then produces a Run-time error '13' and says type mismatch on the highlighted line above. I have declared the ETChours variable as an integer, and the [December_2013_Hours] field is set in access as a number (long integer) data type. Can anyone point me in the direction to figure out why I am getting a Type error?
Thank you!
Code:
Function ETChours() As Integer
userPeriod = "11 / 1 / 2013"
userDate = CDate(userPeriod)
currentMonth = month(userDate)
MsgBox "The Case Statement is selecting: " & currentMonth
Select Case currentMonth
Case 11:
ETChours = [December_2013_Hours]
End Select
End Function
Thank you!