error 3464 Data type mismatch in criteria expression

jocelyn_ooi

Registered User.
Local time
Today, 09:53
Joined
Sep 27, 2011
Messages
17
StrLeaveSql = "SELECT * FROM tblLeave WHERE emp_id = '" & rstReplacement!emp_id & "'" & _
" AND lea_leave_type = '" & Me.txt_leave_type & "'" & _
" AND lea_effective_date = '" & rstReplacement!lea_effective_date & "'" & _
" AND lea_end_date = '" & rstReplacement!lea_end_date & "'"


can anyone help me find out what wrong with my code???
 
Try
Code:
StrLeaveSql = "SELECT * FROM tblLeave WHERE emp_id =" & rstReplacement!emp_id " & _
" AND lea_leave_type = " & Me.txt_leave_type &  _
" AND lea_effective_date = " & rstReplacement!lea_effective_date & _
" AND lea_end_date = " & rstReplacement!lea_end_date & _

The end of the code is not correct, if that is the end of your string
 
Actually if those are date fields, the values need to be surrounded by # rather than '. If either of the other two fields is numeric, they shouldn't have the ' around the value.
 

Users who are viewing this thread

Back
Top Bottom