Dmax Error

B

bsc gmcc

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
 
B

bsc gmcc

Sorry, this is a duplicate. It said my orginal post didn't get sent because
of some error but obviously that wasn't true. I can't figure out how to
delete this one.
 
D

David H

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?
 
D

David H

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top