Solved

data type mismatch in criteria expression error all of a sudden

Posted on 2006-07-06
13
457 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

821 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