Trying to display all the records where printdate is between variables first date and last date but get 'Data type mismatch in criteria expression' - please help im going nuts!
strSQL = "SELECT * FROM tbl_jobs WHERE accounthandler='" & "DT" & "' AND type='" & "Press" & "' AND printdate>='" & firstdate & "' AND printdate<='" & lastdate & "'
2) Are DT and Press variables or constants? If they are constants, then you don't need to add them using concatenates.
Code:
strSQL = "SELECT * FROM tbl_jobs WHERE accounthandler='DT' AND type='Press' AND printdate>='" & firstdate & "' AND printdate<='" & lastdate & "'"
objRS.Open strSQL, objconn
2) Are DT and Press variables or constants? If they are constants, then you don't need to add them using concatenates.
Code:
strSQL = "SELECT * FROM tbl_jobs WHERE accounthandler='DT' AND type='Press' AND printdate>='" & firstdate & "' AND printdate<='" & lastdate & "'"
objRS.Open strSQL, objconn
The statement does have a double quote on the end
strSQL = "SELECT * FROM tbl_jobs WHERE accounthandler='DT' AND type='Press' AND printdate>='" & firstdate & "' AND printdate<='" & lastdate & " ' "
and still returns the error. firstdate + lastdate are variables.
You could also try using CDate() to make sure that they are valid dates and FormatDateTime to make sure that if they are dates they are in the correct format.
Should all the things you have in 's be in 's? If it is a number or whatever it shouldnt be. Dates can be in ' or #