Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange data type mismatch problem 1

Status
Not open for further replies.

postermmxvicom

Programmer
Jun 25, 2007
114
US
I have already made a work around for this problem, but I would like to understand it - not just hack a solution.

I am making a query which groups entries by month and gives me totals. The error I get is:

Data Type Mismatch in criteria expression

The problem is in this little snippet:

Code:
MonthName(Month([DateMelted]))

DateMelted is a Date. I presume MonthName is throwing the error because Month([DateMelted]) returns the month as an integer and works fine. Furthermore if I test something like this:

Code:
MonthName(Month(Now()))

I get no errors and the expression works as anticipated.

One last thing: Sometimes I wonder; "Is that someone's signature? Or do they type that at the end of each post?
 
Does DateMelted sometimes be Null ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
It is sometimes null. I thought that might be a problem; so, I added Is Not Null to the criteria for that.

Is that still the problem?

One last thing: Sometimes I wonder; "Is that someone's signature? Or do they type that at the end of each post?
 
Thanks, PHV.

Got it with this:

Code:
IIf([DateMelted] Is Not ull,MonthName(Month([DateMelted])),"")

and then the criteria

Code:
Not ""

I think I understand why my old way does not work. Thanks again.

One last thing: Sometimes I wonder; "Is that someone's signature? Or do they type that at the end of each post?
 
Obvious typo in the above should read:

Code:
IIf([DateMelted] Is Not Null,MonthName(Month([DateMelted])),"")

One last thing: Sometimes I wonder; "Is that someone's signature? Or do they type that at the end of each post?
 
to the criteria for that
for what ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
to the criteria for that
for what ?

In the query design, I added Is Not Null to the column with the MonthName(Month([DateMelted])). I see now that this does not check to see if DateMelted is null and understand the problem with my thinking.

Thank you so much, PHV.

Aaron




One last thing: Sometimes I wonder; "Is that someone's signature? Or do they type that at the end of each post?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top