Incompatible types using CDate() in Access VBA
问题 I'm calculating with dates in MS Access using VBA. This works fine when I have two dates on the same form (ex 2016-01-21) but not when I first need to modify a string into date form like this: 20160121 -> 2016-01-21. This is what I'm trying to do: Dim sYear As String, sMonth As String, sDay As String, sDate As String sYear = Left("20160121", 4) sMonth = Mid("20160121", 5, 2) sDay = Mid("20160121", 7, 2) sDate = sYear & "-" & sMonth & "-" & sDay MsgBox CDate(sDate) This returns Error 13,