Access 2007/VBA-表单的多个实例,模块上特定实例的更新控件 [英] Access 2007 / VBA - Multiple Instances of Form, Update controls on specific instance from Module
本文介绍了Access 2007/VBA-表单的多个实例,模块上特定实例的更新控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Allen Browne的方法来创建和管理表单的多个实例.我被困在如何从VBA模块引用表单的特定实例上的控件或属性.这是我打开新实例的方法:
I am using Allen Browne's method for creating and managing multiple instances of a form. I am stuck on how to reference controls or properties on a specific instance of the form from a VBA Module. Here is how I open a new instance:
'Purpose: Open an independent instance of form frmMasterRecord.
Dim frm As Form
'Housekeeping
myFilter = Trim("" & myFilter)
'Open a new instance, show it, and set a caption.
Set frm = New Form_frmMasterRecord
frm.ServerFilter = myFilter
frm.ServerFilterByForm = True
frm.Requery
frm.Visible = True
'Append it to our collection.
clnMasterRecord.Add Item:=frm, Key:=CStr(frm.hwnd)
Set frm = Nothing
假设我有三个打开的frmMasterRecord实例.如何在模块中调用子/函数,使其仅在表单的调用实例上操纵控件?
Assume I have three instances of the frmMasterRecord open. How do I call a sub/function in a Module and have it manipulate controls only on the calling instance of the form?
推荐答案
将引用传递给调用表单:
Pass a reference to the calling form:
Result = MyExternalFunction(Me)
和
Public Function MyExternalFunction(ByRef frm As Form) As Boolean
' Do stuff with object frm.
MyExternalFunction = Result
End Function
这篇关于Access 2007/VBA-表单的多个实例,模块上特定实例的更新控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文