Solved

data type mismatch in criteria expression error all of a sudden

Posted on 2006-07-06
13
454 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

867 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

22 Experts available now in Live!

Get 1:1 Help Now