简体   繁体   English

嵌入到导航表单中时,访问VBA子表单不会过滤其他子表单

[英]Access VBA SubForm Not Filtering Other Subform When Embbedded in Navigation Form

I have an unbound form with two subforms embedded into a navigation form, like this: 我有一个未绑定的表单,其中两个子表单嵌入了导航表单,如下所示:

在此处输入图片说明

On the subform on the left side, I have the following code related to the OnFocus Event of the CustomerName field, which filters the subform on the right to show the customer detail that is selected from the right: 在左侧的子窗体上,我具有以下与CustomerName字段的OnFocus事件相关的代码,该代码过滤右侧的子窗体以显示从右侧选择的客户详细信息:

Private Sub CustomerName_GotFocus()

Forms!frmCustomers_sjh![Customer Address Form].Form.Filter = "CustomerName = '" & Me.CustomerName & "'"
Forms!frmCustomers_sjh![Customer Address Form].Form.FilterOn = True

End Sub

This works great when I have the frmCustomers_sjh open by itself, but it craps out when I run it from the Navigation form. 当我自己打开frmCustomers_sjh时,此方法效果很好,但是当我从“导航”表单中运行它时,它会崩溃。 I get Run-Time Error '2450' that Access can't find the referenced form 'frmCustomers_sjh`. 我收到运行时错误“ 2450”,表明Access无法找到引用的形式“ frmCustomers_sjh”。

I've done enough research to know that running the code within the navigation form is different and a bit trickier to play with, but I haven't been able to solve the issue here. 我已经做了大量的研究,知道在导航表单中运行代码是不同的,并且玩起来有些棘手,但是我无法在此处解决问题。

Things to note: 注意事项:

  1. Not using the Navigation Form is not an option (client requirements) 不使用导航表单不是一种选择(客户要求)
  2. Splits Form are not an option either, as I need a search directory on only customer name on the right, with a detail form on left. “拆分表格”也不是一种选择,因为我只需要在右侧的客户名称上有一个搜索目录,在左侧有一个详细表格。
  3. I am open to any other design solutions, as my understanding of Navigation Forms is low since I just started playing with it. 我对任何其他设计解决方案都持开放态度,因为自从我刚开始使用导航表单以来,我对导航表单的理解就很低。

I solved this! 我解决了!

I took out the VBA code and placed a text box with the control source set to the CustomerName field in the subform on the left in the unbound form. 我取出了VBA代码,并将文本框的控件源设置为未绑定表单左侧子窗体中的CustomerName字段。 Then I created the parent-child relationship for the subform on the right between that text box and the CustomerName field in that form! 然后,我在该文本框和该表单中的CustomerName字段之间的右侧为子表单创建了父子关系!

Woohoo! oo!

This link helped a lot! 这个链接很有帮助!

这个额外的站点为我对该错误的体验增加了更多价值: http : //www.mrexcel.com/forum/microsoft-access/635816-visual-basic-applications-buttons-dont-work-navigation-form.html

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

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