[英]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: 注意事项:
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!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.