473,387 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Data type mismatch in criteria expression.

Fary4u
273 100+
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
2 3192
Fary4u
273 100+
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
Nicodemas
164 Expert 100+
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

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

Similar topics

1
by: ArcadeJr | last post by:
Good morning all! I have been getting a Run-time Error message #3464 - Data Type mismatch in criteria expression. While trying to run a query. I have a database where the field Asset_Number...
4
by: N J | last post by:
Hi, CurrentDb.Execute "Update tblDelayedOrders Set DELAYED = True Where ID = " & Me.txtOrderNumber & ";", dbfailonerror Me.StatusListBox.AddItem "ORDER # " & Me.txtOrderNumber & " MARKED AS...
3
by: martlaco1 | last post by:
Trying to fix a query that (I thought) had worked once upon a time, and I keep getting a Data Type Mismatch error whenever I enter any criteria for an expression using a Mid function. Without the...
1
by: amitbadgi | last post by:
I am getting the following error while converting an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Data type mismatch in criteria expression. ...
2
by: technocraze | last post by:
Hi guys, Implementations application & programming environ MS Acess + Visual Basic Table fields Serialno (pk) - Auto number StudentId - text Course - text intake - number
10
by: aaronrm | last post by:
I have a real simple cross-tab query that I am trying to sum on as the action but I am getting the "data type mismatch criteria expression" error. About three queries up the food chain from this...
2
by: psychomad | last post by:
Please, can someone help me out to solve this error, i've been searching throughout my codes and yet i didnt succeed in finding the error!!!! The Error is: Server Error in '/' Application....
19
by: Lysander | last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the...
1
by: DC | last post by:
Any idea why this code would cause a error? The SQL that gets executed seems to be (using record 1132 as an example) DELETE FROM user_table WHERE ID = '1132'; And the value of...
2
by: tmoon3 | last post by:
Hello, This must be a simple mistake, but for some reason I cannot seem to get around it. I am simply trying to create a report of all employees that have a date filled in in a training column...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.