Lock all the controls in a userform

NDMDRB

Board Regular
Joined
Jun 20, 2016
Messages
128
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

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?
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,421
If you look at the Label control Properties you will see there is no Locked.
You can Enable a label or Inable a label but you cannot lock a label.
 
Last edited:

Forum statistics

Threads
1,085,436
Messages
5,383,659
Members
401,845
Latest member
ZmutLarr

Some videos you may like

This Week's Hot Topics

Top