基本SQL UPDATE和Access 2007 vba问题。有人可以向我解释为什么这个查询也在更新BoxType
“60ct托运人托盘”而不只是更新WHERE
声明中声明的60ct托运人件?谢谢!
ElseIf Me!txtBoxType = "60ct Shipper Tray" Then
'Cases that use a 60tray are more complicated. They use 1 each of the base, header, and display
'aswell as 3 shelves.
qdf.SQL = "UPDATE tblBoxList Set Qty = (Qty+(" & Me!txtQtyChange & ")) WHERE BoxType = '60ct Shipper Base' OR '60ct Shipper Header' OR '60ct Shipper Display';"
qdf.Execute dbFailOnError
答案 0 :(得分:2)
您需要在OR
的每个条件中包含字段名称。使用SELECT
查询来计算WHERE
子句逻辑。
SELECT *
FROM tblBoxList
WHERE
BoxType = '60ct Shipper Base'
OR BoxType = '60ct Shipper Header'
OR BoxType = '60ct Shipper Display'
您可能更喜欢这种方法。
WHERE BoxType IN
(
'60ct Shipper Base',
'60ct Shipper Header',
'60ct Shipper Display'
)