If you change Nash's function slightly, you can call it as described...
Code:
Function CheckDate(strDate)
IF IsDate(strDate)Then
CheckDate= "'#" & strDate & "#'"
ELSE
CheckDate= NULL
END IF
End Function
strSQL = "... datefield = " & CheckDate(dtDateVar)