Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

data type mismatch in criteria expression error all of a sudden

Posted on 2006-07-06
13
Medium Priority
?
482 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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 1500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

618 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