I think you need single apostrophes around the State_ID bit as in ...
lngComplaintID = DMax("[StateSeq]", "Complaint", _
"[State_ID] = " & "'" & Forms!Complaint!State_ID & "'" & And
"Year([Date_Received]) =
" & CInt(Year(Forms!Complaint!txtDateReceived))) _
+ 1
I separated them out for clarity.
Typically if you get a Type Mismatch error it means that Access is expecting
one data type but you supplied another. In this instance, I would GUESS that
the State_ID is actually a string value, however as originally written you
supplied as if it was numeric.
I'm assuming that State_Id is comprised of alphanumeric characters?
"bsc gmcc" wrote:
> I am receiving Error 13, Type Mismatch on the following Dmax statement. I
> know that Year([Date_Received]) brings back the year when I run it in a query
> and that CInt(Year(Forms!Complaint!txtDateReceived))) returns the year as
> well. I may not need some of functions such as CInt but I have been playing
> with this to see why the error is occuring with no luck.
>
>
> lngComplaintID = DMax("[StateSeq]", "Complaint", _
> "[State_ID] = " & Forms!Complaint!State_ID And "Year([Date_Received]) =
> " & CInt(Year(Forms!Complaint!txtDateReceived))) _
> + 1
>
> --
> bsc
|