Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42312

Type Mismatch Run-time error '13'

$
0
0
I am not certain why this vba code is producing a type mismatch...

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

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!

Viewing all articles
Browse latest Browse all 42312

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>