[英]ms access 2000: Too few parameters with DSum
I have this problem for like an hour now and I just can't find the solution through Google, so maybe someone here can help me?我现在有这个问题大约一个小时了,但我无法通过谷歌找到解决方案,所以也许这里有人可以帮助我? I have this table here:
我这里有这张表:
|--------------------------|
| Table1 |
| Product | Amount | Buyer |
|--------------------------|
| Food | 4 | 1 |
| Paper | 30 | 1 |
| Food | 2 | 2 |
|--------------------------|
And I want to have this table here:我想把这张桌子放在这里:
|-------------------|
| table2 |
| Buyer | Purchases |
|-------------------|
| 1 | 34 |
| 2 | 2 |
|-------------------|
Before the code is executed, table2 looks like this:在执行代码之前,table2 看起来是这样的:
|-------------------|
| table2 |
| Buyer | Purchases |
|-------------------|
| 1 | |
| 2 | |
|-------------------|
The code I tried is:我试过的代码是:
UPDATE table2
SET Purchases = (
DSum("Amount", "table1", "table1.Buyer = " & table2.Buyer)
)
However, I get the following error:但是,我收到以下错误:
Too few parameters. Expected 1
If I remove the last part of the DSum method:如果我删除 DSum 方法的最后一部分:
UPDATE table2
SET Purchases = (
DSum("Amount", "table1")
)
I don't get an error.我没有收到错误。 What did I do wrong?
我做错了什么?
Don't include the table names:不要包括表名:
UPDATE
table2
SET
Purchases = DSum("Amount", "table1", "Buyer = " & Buyer & "")
No single quotes as Buyer is a number.没有单引号,因为买方是一个数字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.