【发布时间】:2021-06-21 18:52:13
【问题描述】:
我有一个可以从任何表单调用的通用 Sub,它将启用所有将 Tag 属性设置为“EnableForReadOnly”的文本框和组合框。我想为 Subforms 创建类似的东西。
Public Sub EnableReadOnlyControls(theForm)
Dim i As Integer
' Cycle through the form's controls,
For i = 0 To theForm.Count - 1
If theForm(i).Tag = "EnableForReadOnly" Then
If TypeOf theForm(i) Is TextBox Then
theForm(i).Locked = False
theForm(i).Enabled = True
ElseIf TypeOf theForm(i) Is ComboBox Then
theForm(i).Locked = False
theForm(i).Enabled = True
End If
End If
Next i
结束子
要从表单调用这个 Sub,在表单的 OnOpen 事件上,我输入以下内容,效果很好:
EnableReadOnlyControls Me
我想为子表单创建一个类似的通用 Sub,但我不确定是否可以以这种通用方式引用子表单。任何想法将不胜感激。
【问题讨论】:
-
您可以简单地使用相同的功能。
EnableReadOnlyControls Me.SubformControl.Form。或者您在子表单的 Open 事件中的呼叫。 -
感谢@Andre 完美运行!
标签: ms-access reference subform