Problem with Textbox lock/enable

IfButOnly

Registered User.
Local time
Tomorrow, 05:35
Joined
Sep 3, 2002
Messages
236
I am using the code below to lock fields on a form - user can click a Command Button to unlock and edit.

It works fine except where I have an empty Enabled text fields. I can change data in fields that already have data in them, however those that are empty, appear to be Not Enabled - in that, they won't accept the focus when I click to them.

Code:
Private Sub cmdLock_Click()
    fLockScreen (Not (Me.lblLocked.Visible))    'if label visible, screen locked.
End Sub

Private Sub fLockScreen(lswitch As Boolean)
    Dim ctl As Control
    Me.lblLocked.Visible = lswitch      'Label displays 'locked'
    For Each ctl In Me
        If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
            If ctl.Enabled Then        ' if enabled then locked the control
                ctl.Locked = lswitch
            End If
        End If
    Next ctl
End Sub

Does anyone know what the problem is?

Thanks ... Peter
 
Locked and Enabled are two different properties. Looks like your taking them to mean the same thing.
 
No, I am okay there. The reason I am checking for enabled property is that some of the fields are Not Enabled and if I lock them as well then they are greyed out - which I don't want.

I have the same problem if I remove the if ctl.enabled statement.

Any thoughts?
 
Found the problem - unrelated. Duh!

Sorry about that ... Peter
 

Users who are viewing this thread

Back
Top Bottom