简体   繁体   English

使用子窗体的MS ACCESS更新表

[英]MS ACCESS Update Table using Subform

I am creating a form to update my database. 我正在创建一个表单来更新我的数据库。 I would like the user to select two options to filter the results: Month and State Then I would like to populate a subform (in datasheet view) where the user can update the other corresponding columns (amount due, etc) Then I would like a button that uses the imputed data and updates the main database. 我希望用户选择两个选项来过滤结果:月和州然后我想填充一个子表单(在数据表视图中),用户可以在其中更新其他对应的列(应付金额等),然后我想要一个使用估算数据并更新主数据库的按钮。

I created a query to filter the results based on the 2 combo boxes. 我创建了一个查询,以基于2个组合框过滤结果。 When it is populated onto the subform it will not allow editing. 当它填充到子窗体上时,将不允许编辑。

How do I begin to solve this problem? 我如何开始解决这个问题?

*I've tried creating a temporary table using the query results, but I cannot get the temp table to populate into the subform so that I can just write an update query to move the results from the temp table to the main database. *我尝试使用查询结果创建一个临时表,但无法将临时表填充到子表单中,因此我只能编写一个更新查询以将结果从临时表移至主数据库。

Thank you so much! 非常感谢!

Your query is probably not an updateable query so it disallows editing. 您的查询可能不是可更新的查询,因此它不允许编辑。

To use an updateable query or temp table in your subform, you need to use VBA to handle the dynamic process: 若要在子窗体中使用可更新的查询或临时表,您需要使用VBA来处理动态过程:

  1. Create temp table or run the updateable query from form's user-defined filter options. 创建临时表或从表单的用户定义过滤器选项运行可更新查询。
  2. Bound the temp table to the subform's recordsource using Recordsource (example: Forms!MainForm!Subform.Form.Recordsource = "[TEMP TABLE]"). 使用Recordsource将临时表绑定到子窗体的记录源(示例:Forms!MainForm!Subform.Form.Recordsource =“ [TEMP TABLE]”)。
  3. Requery the subform to refresh it as it will not show immediately (example: Forms!MainForm!Subform.Requery). 重新查询子表单以刷新它,因为它不会立即显示(例如:Forms!MainForm!Subform.Requery)。
  4. If using temp table, run your update action query to migrate temp data to actual database table. 如果使用临时表,请运行更新操作查询以将临时数据迁移到实际数据库表。 An updateable query would already connect to your actual table so will not need an update action query. 可更新查询将已经连接到您的实际表,因此将不需要更新操作查询。

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

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