By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,162 Members | 1,061 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,162 IT Pros & Developers. It's quick & easy.

Data type mismatch in criteria expression.

Fary4u
100+
P: 273
using " & variable & " ...
Syntax error (missing operator) in query expression
-----------------------------------------------------
'(orderID=5) and (productID=101) and (prodcolor=Medium) and (prodsize=300x300x300)'.

Expand|Select|Wrap|Line Numbers
  1. ocon2.Execute "DELETE FROM itemsOrdered WHERE (orderID=" & intOrderID & ") and (productID=" & intProdID & ") and (prodcolor=" & stprodcolor & ") and (prodsize=" & stprodsize1 & ")"
  2.  
-----------------------------
if i use ' " & variable & " ' ...

Microsoft JET Database Engine (0x80040E07)
Data type mismatch in criteria expression.
---------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. ocon2.Execute "DELETE FROM itemsOrdered WHERE (orderID='" & intOrderID & "') and (productID='" & intProdID & "') and (prodcolor='" & stprodcolor & "') and (prodsize='" & stprodsize1 & "')"
  2.  
Jan 30 '12 #1
Share this Question
Share on Google+
2 Replies


Fary4u
100+
P: 273
Problem with Numeric and string value even doing the rite way but still giving the error ?

Expand|Select|Wrap|Line Numbers
  1. datafiled no: work fine| intOrderID = "7"
  2. datafiled no: work fine| intProdID = "2"
  3. datafiled Chr: work fine| stprodcolor = "Medium"
  4. datafiled Chr: data mismatch| stprodsize = "400x400x400"
  5. datafiled Chr: no value given| ncolr = "Black"
  6.  
  7.  
  8. intOrderID = "7"
  9. intOrderID = cStr(intOrderID)
  10. intProdID = "2"
  11. intProdID = cStr(intProdID)
  12. stprodcolor = "Medium"
  13. stprodsize = "400x400x400"
  14. stprodsize = cStr(stprodsize)
  15. ncolr = "Black"
  16. ncolr = cStr(ncolr)
  17.  
  18. SQL = "DELETE FROM itemsOrdered WHERE (orderID=" & intOrderID & ") and (productID=" & intProdID & ") and (prodcolor=" & stprodcolor & ") and (colour=" & ncolr & ") and (size=" & stprodsize &")"
  19.  
Jan 30 '12 #2

Expert 100+
P: 164
Do not type cast the variables. You have already made them strings by wrapping them in quotation marks.

Your SQL statement will also fail because you must wrap any string variable in single quotes and any numeric variables must not be within quotes. Check your code for this.
Feb 2 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.