Data type mismatch in criteria expression.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Fary4u
    Contributor
    • Jul 2007
    • 273

    Data type mismatch in criteria expression.

    using " & variable & " ...
    Syntax error (missing operator) in query expression
    -----------------------------------------------------
    '(orderID=5) and (productID=101) and (prodcolor=Medi um) and (prodsize=300x3 00x300)'.

    Code:
    ocon2.Execute "DELETE FROM itemsOrdered WHERE (orderID=" & intOrderID & ") and (productID=" & intProdID & ") and (prodcolor=" & stprodcolor & ") and (prodsize=" & stprodsize1 & ")"
    -----------------------------
    if i use ' " & variable & " ' ...

    Microsoft JET Database Engine (0x80040E07)
    Data type mismatch in criteria expression.
    ---------------------------------------------
    Code:
    ocon2.Execute "DELETE FROM itemsOrdered WHERE (orderID='" & intOrderID & "') and (productID='" & intProdID & "') and (prodcolor='" & stprodcolor & "') and (prodsize='" & stprodsize1 & "')"
    Last edited by Fary4u; Jan 30 '12, 09:31 PM. Reason: get space
  • Fary4u
    Contributor
    • Jul 2007
    • 273

    #2
    Problem with Numeric and string value even doing the rite way but still giving the error ?

    Code:
    datafiled no: work fine| intOrderID = "7"
    datafiled no: work fine| intProdID = "2"
    datafiled Chr: work fine| stprodcolor = "Medium"
    datafiled Chr: data mismatch| stprodsize = "400x400x400"
    datafiled Chr: no value given| ncolr = "Black"
    
    
    intOrderID = "7"
    intOrderID = cStr(intOrderID)
    intProdID = "2"
    intProdID = cStr(intProdID)
    stprodcolor = "Medium"
    stprodsize = "400x400x400"
    stprodsize = cStr(stprodsize)
    ncolr = "Black"
    ncolr = cStr(ncolr)
    
    SQL = "DELETE FROM itemsOrdered WHERE (orderID=" & intOrderID & ") and (productID=" & intProdID & ") and (prodcolor=" & stprodcolor & ") and (colour=" & ncolr & ") and (size=" & stprodsize &")"
    Last edited by Fary4u; Jan 30 '12, 09:25 PM. Reason: wrong arrgument

    Comment

    • Nicodemas
      Recognized Expert New Member
      • Nov 2007
      • 164

      #3
      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.

      Comment

      Working...