如何重建活动表单的源表?
我有一个访问表单,其源数据是 2 个表,我们将它们称为 TblA
和 TblB
。该表单具有一个控件,该控件应该:
- 将用户的一些新数据捕获到第三个表中。
- 运行 maketable 查询,使用新数据重新创建 TblA 和 TblB。
- 重新查询&刷新表格。
但是,我遇到了问题。 maketable 查询失败。我认为这是因为我打开了主窗体。这是一个代码片段:
Dim AccDB As New Access.Application
AccDB.OpenCurrentDatabase DbLoc
AccDB.DoCmd.OpenQuery "TblA-Rebuild"
AccDB.DoCmd.OpenQuery "TblB-Rebuild"
Forms("Frm").Requery
我的问题是:如何重写此过程以成功重建这些表?
I have an Access Form whose source data is 2 tables, let's call them TblA
and TblB
. This form has a control that should:
- Capture some new data from the user into a 3rd table.
- Run maketable queries recreating TblA and TblB with the new data.
- Requery & refresh the form.
However, I'm running into a problem. The maketable queries are failing. I assume this is because I have the main form open. Here's a code snippet:
Dim AccDB As New Access.Application
AccDB.OpenCurrentDatabase DbLoc
AccDB.DoCmd.OpenQuery "TblA-Rebuild"
AccDB.DoCmd.OpenQuery "TblB-Rebuild"
Forms("Frm").Requery
My question is: How do rewrite this process to successfully rebuild these tables?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我进一步建议您使用删除查询来清除内容,然后使用追加查询来重新填充表,而不是重新创建表。与正在使用的表没有冲突,并且您不会丢失索引或特定于字段的属性等表设置。
I would further suggest rather than re-creating the tables that you use a delete query to clear the contents and then an append query to refill the table. No conflicts with the table being in use and you don't lose table settings like indexes or field-specific properties.
我会将您现有的表单嵌入到未绑定到表的子表单中。然后,您可以在重新制作表格时关闭子表单并再次打开它。
I would embed your existing form into a subform that isn't bound to a table. Then you can close your subform while you're remaking the tables and open it again.