Solved

data type mismatch in criteria expression error all of a sudden

Posted on 2006-07-06
13
460 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
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.

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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 functions 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 Ac…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

828 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