更新 Access 中的多值字段
我在 Access 中创建了一个查找表来提供列的可能值。现在,我需要使用转换列之前的数据更新此列。我无法找出可行的 SQL 查询。我不断收到错误“更新或删除查询不能包含多值字段。”我的研究表明我只需要设置该列的值,但这总是更新 0 条记录:
UPDATE [table_name] SET [column_name].Value = 55 WHERE [table_name].ID = 16;
我知道如果我将其更改为更新文本列,则该查询将起作用,因此这绝对是该列的问题。
I have created a lookup table in Access to provide the possible values for a column. Now I need to update this column with the data it had before I converted the column. I am unable to figure out a SQL Query that will work. I keep getting the error "An UPDATE or DELETE query cannot contain a multi-valued field." My research has suggested that I just need to set the value of the column but this always updates 0 records:
UPDATE [table_name] SET [column_name].Value = 55 WHERE [table_name].ID = 16;
I know this query will work if I change it to update a text column, so it is definitely a problem with just this column.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果您要向多值字段添加值,请使用追加查询。
如果您想要更改多值字段中存在的一个特定值,请使用 UPDATE 语句。例如,要将 55 更改为 56 ...
请参阅 在查询中使用多值字段了解更多信息。
If you're adding a value to your multi-valued field, use an append query.
If you want to change one particular value which exists in your multi-valued field, use an UPDATE statement. For example, to change the 55 to 56 ...
See Using multivalued fields in queries for more information.
我已经弄清楚了!这确实是违反直觉的!您必须使用 INSERT 语句来进行更新。
这让我很困惑,因为我期待一个 UPDATE 语句。我认为它实际上将一条记录插入到一个隐藏表中,该表用于将多个值与该列相关联。
I have figured this out! It certainly was counter-intuitive! You have to use an INSERT statement to do the update.
This confused me because I was expecting an UPDATE statement. I think it actually inserts a record into a hidden table that is used to associate multiple values with this column.
我正在使用 Sharepoint,我将表创建为多值字段,在使用
INSERT INTO
语句时遇到错误,返回 Sharepoint 更改为非多值字段,但这并没有不修它。不使用多值字段重新创建了表,
INSERT INTO
工作得很好。I am working with Sharepoint, I created the tables as multi-value fields, ran into the error with my
INSERT INTO
statement, went back to Sharepoint to change to non-multi-value fields, but that didn't fix it.Recreated the table without using multi-value fields, and the
INSERT INTO
worked just fine.不要使用 .value 部分
do not use the .value part
我得说我不太明白你的问题,但我在你的查询中看到了一些奇怪的东西。试试这个:
更新:
看看这个< /a> 链接:它有一个示例
I gotta say I didn't understand very well your problem but I saw something strange in your query. Try this:
UPDATE:
Look at this link: it has an example
多值字段是指具有带列的表的 Access 数据库,允许您选择多个值,如组合复选框列表。
这些是 SQL 无法使用的唯一 Access 类型。我已经测试了所有 Access 查找的可能性,包括硬编码值和查找表。它们工作正常,但如果您有一列具有“允许多个选择”选项,那么您就不走运了。即使使用下面提到的 INSERT INTO ,也不会起作用,因为您会收到关于 INSERTing 到多值字段的类似但不同的错误。
如前所述,最好避免在 Access 外部使用此类表,并专门针对您的外部需求引用表。然后编写一个宏/vba 脚本以使用“辅助”表中的数据更新真实表。
The Multi-Valued field refers to Access databases that have tables with columns, that allow you to select multiple values, like a Combo Checkbox list.
THOSE are the only Access types that SQL cannot work with. I've tested all Access lookup possibilities, including hard-coded values, and lookup tables. They work fine, but if you have a column that has the Allow Multiple select options, you're out of luck. Even using the INSERT INTO as mentioned below, will not work as you'll get a similar but different error, about INSERTing into multi-valued fields.
As mentioned it's best to avoid using such tables outside of Access, and refer to a table specifically for your external needs. Then write a macro/vba script to update the real tables with the data from the "auxiliary" table.