Lock field after update

  • Thread starter Thread starter julief
  • Start date Start date
J

julief

I have a yes/no field on a form which I want to lock if field is yes.

I have tried a few bits of code but not had any luck.

Could someone please point me in the right direction.
 
julief said:
I have a yes/no field on a form which I want to lock if field is yes.
I have tried a few bits of code but not had any luck.
Could someone please point me in the right direction.

So you want that check box to be locked in any record where its value is
Yes?

Use the Current event of the form to lock it as soon as you arrive at that
record. Run the same code in the AfterUpdate event of the *form*, so it
locks as soon as that record is saved. (You don't want it locked until the
record is saved.)

This kind of thing:

Private Sub Form_Current()
Dim bLock As Boolean
With Me.[PutTheNameOfYourCheckBoxHere]
If (.Value) then
bLock = True
If Me.ActiveControl.Name = .Name Then
Me.[PutAnotherControlNameHere].SetFocus
End If
End If
If .Locked <> bLock Then
.Locked = bLock
End If
End With
End Sub

Private Sub Form_AfterUpdate()
Call Form_Current
End Sub
 
Back
Top