MS Access 2007 子表单在表单标题上重新加载 = 可见?
我在 Access 2007 中在 Access 2003 中设计的窗体上遇到奇怪的行为。
我有一个带有数据绑定子窗体的未绑定主窗体。在主窗体的 Form_load 中,我设置了子窗体源对象,它加载子窗体记录集等。子窗体加载后,但仍在主窗体的 Form_load 中,我设置 Me.FormHeader.Visible = True< /代码>。此行运行后,由于某种原因,子窗体似乎关闭并重新打开 - 它的 Form_Unload 触发,并再次运行其加载过程。
知道为什么会发生这种情况吗?这很烦人,因为它的记录集基于参数查询,并且在重新加载时参数会被破坏,因此最终会提示用户输入参数。
I'm getting strange behavior in Access 2007 on a form designed in Access 2003.
I have an unbound main form with a data-bound subform. Within the Form_load of the main form, I set the subform sourceobject, which loads the subform recordset, etc. After the subform loads, but still within the Form_load of the main form, I set Me.FormHeader.Visible = True
. After this line runs, for some reason the subform seems to close and reopen -- its Form_Unload fires, and it runs through its load process again.
Any idea why this would be happening? It's annoying, because its recordset is based on a parameter query, and the parameters get zapped when it reloads so it ends up prompting users for parameters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有时您必须忍受(并解决)MS Access 的行为,无论它多么奇怪或烦人。
在这种情况下,我可能会建议您放弃参数查询,而是使用 VBA 提示用户输入,将其输入存储在表单级变量中,并在子表单的 Form_Load 事件期间使用该输入设置记录源。这样,用户只会被提示一次,而无需知道表单实际上加载了两次。
Sometimes you have to live with (and work around) the behavior of MS Access, no matter how strange or annoying it is.
In this case I would probably advise that you move away from a parameter query and instead prompt the user for their input using VBA, store their input in a form level variable, and use that input to set the recordsource during the subform's Form_Load event. This way the user will only be prompted one time and never need to know that the form actually loaded twice.