Solved

data type mismatch in criteria expression error all of a sudden

Posted on 2006-07-06
13
452 Views
Last Modified: 2012-06-27
Hi all.

I have a report that has been working correctly for the past 3 months, but today I tried running it and I got the following error:

data type mismatch in criteria expression

and I figured where the error is occuring. The Expression is called Expr27 and it has a criteria of >0. When I take off the >0 it seems to work, but I need that criteria there, any ideas why it stopped working all of sudden.

Thanks.
0
Comment
Question by:printmedia
  • 5
  • 3
  • 3
  • +2
13 Comments
 
LVL 35

Expert Comment

by:Raynard7
ID: 17055217
this means that somehow the data is now not a number - and as such you can not test if it is > 0

What you can do is wrap the expression in expressionName: clng({Current Expression Code}) and now the test should work.

0
 

Author Comment

by:printmedia
ID: 17055246
I tried that and it still does not work.
0
 
LVL 10

Expert Comment

by:LenaWood
ID: 17055255
Could you have a null value in the field that you are checking for >0 or even a space?  What is the Expression you are creating?

Lena
0
 
LVL 26

Expert Comment

by:jerryb30
ID: 17055270
What is the expression definition?   Are you grouping in the report source query?
0
 

Author Comment

by:printmedia
ID: 17055280
There are no null values, I don't think there are any spaces, but when I put any type of criteria it gives me the error.

I tried "0" and Not "0" and it still gave me an error.
0
 

Author Comment

by:printmedia
ID: 17055288
But if I do the following it works:

Like "21254.4" or Like "0" it works, in other words the query returns the records with those values.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 26

Expert Comment

by:jerryb30
ID: 17055296
Seems like field has turned into a text field.  Can you post the entire sql?
0
 

Author Comment

by:printmedia
ID: 17055352
SELECT [Stock Overage by Qty in Months Query 2].Expr27, [Stock Overage by Qty in Months Query 2].Expr24, [Stock Overage by Qty in Months Query 2].Expr23, [Stock Overage by Qty in Months Query 2].Item
FROM [Stock Overage by Qty in Months Query 2]
WHERE ((([Stock Overage by Qty in Months Query 2].Expr27)>0));


Stock Overage by Qty in Months Query 2 listed above:


SELECT [Item Stock Amount Audit 1].Item, [Item Stock Amount Audit 1].Expr8, [Item Stock Amount Audit 1].Expr15, [Item Stock Amount Audit 1].DateLastSold, IM_M1_Dinfo.Productdescript, [Item Stock Amount Audit 1].ReorderPointQty, [Item Stock Amount Audit 1].Expr1 AS Overage, [Item Stock Amount Audit 1].Expr10 AS [Total Months of Stock], [Item Stock Amount Audit 1].Expr2 AS [Total Months to Keep In Stock], [Item Stock Amount Audit 1].Expr4 AS [Total Months Over], [Item Stock Amount Audit 1].StdCost, [Item Stock Amount Audit 1].QtyOnHand, [Item Stock Amount Audit 1].Safety_Stock, [Item Stock Amount Audit 1].Expr20, [Item Stock Amount Audit 1].Expr21, [Item Stock Amount Audit 1].Expr2, [Item Stock Amount Audit 1].Expr22, IIf([Expr22] Like "N*",[QtyOnHand]*[StdCost],(([Expr22]-[Safety_Stock])*[Expr20])*[StdCost]) AS Expr23, Val(IIf([Expr22] Like "N*",Round([QtyOnHand]/30,4),[Expr22])) AS Expr24, IIf([Expr23]<0,0,[Expr23]) AS Expr30, IIf(Round([Expr24],0)<=9,[Expr30],0) AS Expr25, IIf(Round([Expr24],0)>=10 And Round([Expr24],0)<=12,[Expr30],0) AS Expr26, IIf(Round([Expr24],0)>=13,[Expr30],0) AS Expr27, Val([Expr23]) AS Expr11, IIf([Expr11]>0,[Expr11],0) AS Expr12, IIf([Expr11]<0,[Expr11],0) AS Expr13
FROM [Item Stock Amount Audit 1] LEFT JOIN IM_M1_Dinfo ON [Item Stock Amount Audit 1].Item = IM_M1_Dinfo.ItemNumber
WHERE ((([Item Stock Amount Audit 1].Expr8) Is Not Null))
ORDER BY Val(IIf([Expr22] Like "N*",Round([QtyOnHand]/30,4),[Expr22])) DESC;
0
 
LVL 26

Expert Comment

by:jerryb30
ID: 17055622
Wow.  The [expr] make this a bit of a challenge, it seems that the answer still lies in datatype of expr27.  Something has allowed an unexpected value into expr24 or expr30, which turns the value into a text field, I think.  You might try turning the second displayed query into a make table query, and see what datatype expr27 comes up as.  That doesn't necessarily answer the fix, but it might be a start.  Then, you have to work out withing the chain of queries creating [item stock amount audit1], to find where the unexpected value comes in.  
Or, you might try something as simple as:
IIf(Round(nz([Expr24],0),0)>=13,nz([Expr30],0),0)
inserted into the appropriate place.

0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 17055631
WHERE (((Val([Stock Overage by Qty in Months Query 2].Expr27))>0));
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 17055637
sorry, one too many paren

WHERE ((Val([Stock Overage by Qty in Months Query 2].Expr27)>0));
0
 

Author Comment

by:printmedia
ID: 17057977
I created tables for those queries in they all have Expr27 appearing as a number.

The Val() function did not work nor did the nz() function.
0
 
LVL 34

Accepted Solution

by:
jefftwilley earned 500 total points
ID: 17058220
In your second SQL above, Expr22 looks like text, yet your logic for Expr25, 27 and 27 treat it as if it were numeric

IIf([Expr22] Like "N*",[QtyOnHand]*[StdCost],(([Expr22]-[Safety_Stock])*[Expr20])*[StdCost]) AS Expr23,
                        ~~                                        ~~~~~~~~~~~~~~~~

Val(IIf([Expr22] Like "N*",Round([QtyOnHand]/30,4),[Expr22])) AS Expr24,  
                               ~~                                         ~~~~~

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now