sql = "UPDATE tblProduct SET Amount = Amount - " & _
            IncAmount & " WHERE ProductID =" & ProductID
我这个SQL查询语句是不是语法上有错误啊?

解决方案 »

  1.   

    sql = "UPDATE tblProduct SET Amount = " & Amount - IncAmount & " WHERE ProductID =" & ProductID & ""
      

  2.   

    注意字段类型,建议将SQL语句输出来到查询分析器中执行通过了,再写到程序里!!
      

  3.   

    如果ProductID是字符,则需要加单引号
    sql = "UPDATE tblProduct SET Amount = " & Amount - IncAmount & " WHERE ProductID ='" & ProductID & "'"
      

  4.   

    恩,tblProduct是一个库存表,ProductID是库存表自动生成的ID,要执行在出库的时候,自动减去输入的数量
      

  5.   

    试试这个
    sql = "UPDATE tblProduct SET Amount = Amount - " & IncAmount & " WHERE ProductID ='" & ProductID & "'"
      

  6.   

    ProductID是根据出库单中选择的物品自动识别的
    IncAmount就是出库单中填写的数量
      

  7.   

    如果ProductID类型是数字型就没问题sql = "UPDATE tblProduct SET Amount = Amount - " & _
                IncAmount & " WHERE ProductID =" & ProductID
      

  8.   

    sql = "UPDATE tblProduct SET Amount = Amount -IncAmount "
    sql=sql &  WHERE ProductID =" & ProductID &""
      

  9.   

    mCon.Execute "UPDATE tblProduct SET Amount = Amount -IncAmount WHERE ProductID  =  ProductID "
      

  10.   

    语句没任何问题,不过可能你没有注意到字段的类型,特别是ProductID字段,看一下是否是字符型的数据,导致了执行出错。
      

  11.   

    sql = "UPDATE tblProduct SET Amount = Amount - '" & _
                IncAmount & "' WHERE ProductID ='" & ProductID & "'"单引号问题