You will get that error when [Line_off_Date]
is Null as this Immediate window session illustrates.
Line_off_Date = Null
? Month(Line_off_Date) & "/1/" & Year(Line_off_Date)
/1/
? CDate("/1/") ' throws Type mismatch (Error 13)
You can update the table to replace Nulls in [Line_off_Date]
. Or you can add a WHERE
clause to exclude rows which have Null for [Line_off_Date]
. Or you can use an IIf
expression which returns the CDate
expression when [Line_off_Date]
is not Null, but something else (perhaps Null?) when [Line_off_Date]
is Null.
As a side point, consider a DateSerial
expression in place of what you were using.
Line_off_Date = Date()
? CDate(Month(Line_off_Date) & "/1/" & Year(Line_off_Date))
12/1/2013
? DateSerial(Year(Line_off_Date), Month(Line_off_Date), 1)
12/1/2013