Toggle button to lock record (1 Viewer)

jonathanchye

Registered User.
Local time
Today, 06:53
Joined
Mar 8, 2011
Messages
448
Hi all,

I would like to create a lock button on top of my form to lock and unlock editing to a specific record.

What I am doing now is add a toggle button and the following code for my form :
Code:
Private Sub tglLock_Click()
Me.AllowEdits = Not Me.AllowEdits

Me.tglLock.Caption = IIf(Me.AllowEdits, "Lock", "Unlock")

End Sub

However this is not really working well. I can still alter fields in the form. Is there a way to prevent any editing at all for that current record ie all fields are locked and non clickable?

Thank you.
 
Last edited:

Chrism2

Registered User.
Local time
Today, 06:53
Joined
Jun 2, 2006
Messages
161
Hi all,

I would like to create a lock button...

Thank you.

Whenever I do this, I usually lock down / unlock the fields with the following code:

Code:
Dim ctl as control

 For Each ctl In Me.Form

            If ctl.Tag = "LockMeDown" Then  'In the controls' properties, set the tag
                ctl.Locked = True 'Can't be edited
                ctl.Enabled = False  'Can't be clicked
                ctl.BackColor = 16777215  'Changing the colour of the box is a nice touch
            End If

 Next ctl

I usually lock down using the same routine (kind of in reverse) on the Form_Open and then use the above on the unlock trigger...
 
Last edited:

Users who are viewing this thread

Top Bottom