使用VBA中另一个表的值和更新表

时间:2014-02-25 17:36:43

标签: ms-access access-vba

我想将table1中的sum(columne)更新为table2中的列 我试着在sql中这样做:

UPDATE stock SET stock.chairout = (SELECT SUM(chairs_count) FROM Event
)
WHERE (([Event].[returned]))=False;

但它给了我错误(它不是更新能查询)

你能帮忙解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

您的查询是:

UPDATE stock 
SET stock.chairout = 
(
  SELECT SUM(chairs_count) 
  FROM Event
)
WHERE Event.returned = False

你的where子句不应该在括号内,如下:

UPDATE stock 
SET stock.chairout = 
(
  SELECT SUM(chairs_count) 
  FROM Event
  WHERE Event.returned = False
)