Private Sub DisableControls(Frm As Form, CtrlTypeName As String)Of course, the actual modification(s) done to the controls inside the loop can be anything, as long as the methods and properties are defined for the type of control that you pass. Use of the function would be something like: DisableControls Me, "TextBox"
Dim nCount As Integer
For nCount = 0 To Frm.Controls.Count - 1
If TypeName(Frm.Controls(nCount)) = CtrlTypeName Then
Frm.Controls(nCount).Enabled = False
End If
Next
End Sub
That would disable all TextBoxes on the form.
No comments:
Post a Comment