I am trying to join a table to a query in MS Access. The field for the query is "LineoffMonth", and the field for the table is "Production Month". LineoffMonth looks like this:
LineoffMonth: CDate(Month([Line_off_Date]) & "/1/" & Year([Line_off_Date]))
Production Month is a date/time data type. I keep getting "Data type mismatch error in expression". I do not understand why it will not let me join the two fields.
You will get that error when
[Line_off_Date]is Null as this Immediate window session illustrates.You can update the table to replace Nulls in
[Line_off_Date]. Or you can add aWHEREclause to exclude rows which have Null for[Line_off_Date]. Or you can use anIIfexpression which returns theCDateexpression when[Line_off_Date]is not Null, but something else (perhaps Null?) when[Line_off_Date]is Null.As a side point, consider a
DateSerialexpression in place of what you were using.