【发布时间】:2017-03-23 09:11:32
【问题描述】:
我有一个包含许多子表单(和子子表单)的主表单。我想在我的主子窗体上有一个按钮,它将每个子窗体从启用 = true 切换到启用 = false。是否可以在不必专门引用每个子表单的情况下做到这一点?可能类似于:对于 frmMainForm 的每个子表单...?
【问题讨论】:
我有一个包含许多子表单(和子子表单)的主表单。我想在我的主子窗体上有一个按钮,它将每个子窗体从启用 = true 切换到启用 = false。是否可以在不必专门引用每个子表单的情况下做到这一点?可能类似于:对于 frmMainForm 的每个子表单...?
【问题讨论】:
是的,您可以循环控制:
For Each Control In Me.Controls
If Control.ControlType = acSubform Then
' Do something with this subform control.
End If
Next
【讨论】:
For Each Control In Me.Controls
If Control.ControlType = acSubform Then
If Control.Name = sSubform Then
Control.Visible = True
Else
Control.Visible = False
End If
End If
Next
help4access.com 使用此方法打开/或当许多子表单包含在单个主表单中时。
【讨论】:
要切换布尔设置,请将其设置为 Not 本身。我还提供了另一种方法来检查适用于所有对象的对象类型,而不仅仅是可能具有或不具有 ControlType 属性的控件。
For Each Control In Me.Controls
If TypeOf Control Is SubForm Then
Control.Visible = Not Control.Visible
End If
Next
【讨论】: