Access 2007 / VBA - 表单的多个实例,更新模块中特定实例的控件
Access 2007 / VBA - Multiple Instances of Form, Update controls on specific instance from Module
我正在使用 Allen Browne 的方法来创建和管理表单的多个实例。我被困在如何从 VBA 模块引用表单特定实例的控件或属性上。以下是我如何打开一个新实例:
'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 实例。如何在模块中调用 sub/function 并让它仅在窗体的调用实例上操作控件?
传递对调用表单的引用:
Result = MyExternalFunction(Me)
和
Public Function MyExternalFunction(ByRef frm As Form) As Boolean
' Do stuff with object frm.
MyExternalFunction = Result
End Function
我正在使用 Allen Browne 的方法来创建和管理表单的多个实例。我被困在如何从 VBA 模块引用表单特定实例的控件或属性上。以下是我如何打开一个新实例:
'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 实例。如何在模块中调用 sub/function 并让它仅在窗体的调用实例上操作控件?
传递对调用表单的引用:
Result = MyExternalFunction(Me)
和
Public Function MyExternalFunction(ByRef frm As Form) As Boolean
' Do stuff with object frm.
MyExternalFunction = Result
End Function