简体   繁体   English

使用Access 2003附加查询

[英]Append Query using Access 2003

I am helping a small school with their database which I created three years ago and that works fine. 我正在帮助一所小型学校使用他们三年前创建的数据库,并且效果很好。 I am now creating a attendance register as a new feature to it and am struggling with the update query fields. 我现在正在创建一个考勤登记册作为它的一项新功能,并且在更新查询字段中苦苦挣扎。

I have two tables and one append query which works well with the form I have created. 我有两个表和一个追加查询,可以很好地与我创建的表单一起使用。 I have combobox to filter the class to check the register which works well. 我有组合框来过滤该类,以检查运行良好的寄存器。 The problem I am faced with is when running the query, it updates all 180 students and not the ones filtered per class. 我面临的问题是运行查询时,它会更新所有180名学生,而不是每个班级过滤的学生。

I need to append the data only for the class selected. 我只需要为选定的类附加数据。 Thank You 谢谢

Please help. 请帮忙。 Harry 哈利

It seems that you wish to only update or append the rows that match the combobox on your form. 看来您只希望更新或追加与表单上的组合框匹配的行。 You can refer to an open form in a query in MS Access. 您可以在MS Access的查询中引用打开的表单。 With your append query in design view, under the field that you want to match and type in Form! 在设计视图中的追加查询中,在要匹配的字段下并在Form中输入! followed by the name of your form, another dot or exclamation, and the name of your combo, say: 接着是您的表格名称,另一个圆点或感叹号以及您的组合名称,例如:

Forms!Form1!Combo0

In SQL View an append query would look something like: 在SQL View中,追加查询如下所示:

INSERT INTO Table1 ( AText )
SELECT Table2.AText
FROM Table2
WHERE Table1.ID=[Forms]![Form1]![Combo0]

Similarly for an update query: 同样,对于更新查询:

UPDATE Table1b 
SET Table1b.ADate = Date()
WHERE Table1b.ID=[Forms]![Form1]![Combo0]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM