Hello,
I have a userform with many Textboxes, Labels, CommandButtons....
I need to lock all the controls when the userform Initializes
Instead of locking each control separate, I found this code on google that works well if the userform doesn't contain any label, else if there is any label, there will be an error
Can someone please tell me how to fix this code to lock all the controls in the userform even if it contains labels?
I have a userform with many Textboxes, Labels, CommandButtons....
I need to lock all the controls when the userform Initializes
Instead of locking each control separate, I found this code on google that works well if the userform doesn't contain any label, else if there is any label, there will be an error
Code:
Private Sub UserForm_Initialize()
Dim ctrl As Control
For Each ctrl In Box.Frame1.Controls
ctrl.Locked = True
Next
Set ctrl = Nothing
Me.cmd_New.Locked = False
End Sub
Can someone please tell me how to fix this code to lock all the controls in the userform even if it contains labels?