Link to home
Start Free TrialLog in
Avatar of CMHamrick
CMHamrick

asked on

Lock all text boxes on a form

I have a form that has several text boxes on it. I wish to LOCK all the text boxes until a certain condition s met.  Is there a way to LOCK all text fields with having to lock each one by its property screen?

The boxes are all named:   textFields(1)    textFields(2)   textFields(3),     etc....

Thanks

Charlie

Avatar of zzzzzooc
zzzzzooc

Private Sub Form_Load()
    'Sets .Locked=True for all TextBoxes on Form1
    Dim ctrlText As TextBox
    For Each ctrlText In Me.Controls
        ctrlText.Locked = True
    Next ctrlText
End Sub
'use the KeyPress event.

Private Sub textFields_KeyPress(Index As Integer, KeyAscii As Integer)
If "your condition" = "criteria" Then
    textFields(Index).Locked = True
End If
End Sub

S
Avatar of CMHamrick

ASKER

That did not work... error on:       ctrlText     ????
ASKER CERTIFIED SOLUTION
Avatar of zzzzzooc
zzzzzooc

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial