PC Review


Reply
Thread Tools Rate Thread

Dmax Runtime error 13, Type mismatch

 
 
bsc gmcc
Guest
Posts: n/a
 
      9th Feb 2009
I am receiving a Runtime error 13, Type mismatch error when running the
below. I know that CInt(Year(Forms!Complaint!txtDateReceived)) returns the
year such as 2009 which is what I want. I also know that if I run a query
with Year([Date_Received]) it also returns the year. So, I have been playing
with this and still can't figure out why I am getting the error.


lngComplaintID = DMax("[StateSeq]", "Complaint", _
"[State_ID] = " & Forms!Complaint!State_ID And "Year([Date_Received]) =
" & CInt(Year(Forms!Complaint!txtDateReceived))) _
+ 1


--
bsc
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      9th Feb 2009
"bsc gmcc" <(E-Mail Removed)> wrote in message
news:481DBE6E-9297-4023-81FA-(E-Mail Removed)...
>I am receiving a Runtime error 13, Type mismatch error when running the
> below. I know that CInt(Year(Forms!Complaint!txtDateReceived)) returns the
> year such as 2009 which is what I want. I also know that if I run a query
> with Year([Date_Received]) it also returns the year. So, I have been
> playing
> with this and still can't figure out why I am getting the error.
>
>
> lngComplaintID = DMax("[StateSeq]", "Complaint", _
> "[State_ID] = " & Forms!Complaint!State_ID And "Year([Date_Received]) =
> " & CInt(Year(Forms!Complaint!txtDateReceived))) _
> + 1



You've got your quotes misplaced in one spot. It seems to me you may also
have a problem if there are no records that meet your criteria, in which
case DMax will return Null. Try this:

lngComplaintID = 1 + _
Nz( _
DMax("[StateSeq]", "Complaint", _
"[State_ID] = " & Forms!Complaint!State_ID & _
" And Year([Date_Received]) = " & _
Year(Forms!Complaint!txtDateReceived)), _
0)


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
Reply With Quote
 
fredg
Guest
Posts: n/a
 
      9th Feb 2009
On Mon, 9 Feb 2009 07:17:02 -0800, bsc gmcc wrote:

> I am receiving a Runtime error 13, Type mismatch error when running the
> below. I know that CInt(Year(Forms!Complaint!txtDateReceived)) returns the
> year such as 2009 which is what I want. I also know that if I run a query
> with Year([Date_Received]) it also returns the year. So, I have been playing
> with this and still can't figure out why I am getting the error.
>
> lngComplaintID = DMax("[StateSeq]", "Complaint", _
> "[State_ID] = " & Forms!Complaint!State_ID And "Year([Date_Received]) =
> " & CInt(Year(Forms!Complaint!txtDateReceived))) _
> + 1


There is a difference in usage between the word And and the Ampersand
(&).

lngComplaintID = DMax("[StateSeq]", "Complaint", "[State_ID] = " &
Forms!Complaint!State_ID & " And Year([Date_Received]) = " &
Year(Forms!Complaint!txtDateReceived)) + 1

The above assumes the [State_ID] criteria field is a Number datatype,
and [Date_Received] is a Date datatype.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DMax Problem (Type Mismatch) DS Microsoft Access Form Coding 11 9th Jun 2005 10:37 PM
Runtime error 13 type mismatch ? JoeH Microsoft Excel Programming 1 25th Sep 2004 04:57 PM
Runtime Error 13 type mismatch LisaB Microsoft Access VBA Modules 9 22nd Sep 2004 08:24 PM
Runtime-Error 13 Type mismatch jack-geronimo Microsoft Access Forms 4 15th Jan 2004 12:21 PM
Runtime Error 13 Type Mismatch Cameron Evenson Windows XP Performance 1 14th Oct 2003 10:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:47 PM.