I have a dataset subform on which I want to lock a field for just two specific records. Each record has a type_id and a desc field. I want to test the value of the type_id field for the current record and if it is "PROD" or "LIBR" I want to lock the field. (I can allow editing of the desc field.) type_id field for all other records should remain unlocked. Here is my code:
The message box is displaying correctly but I can still edit the PROD or LIBR records after dismissing the box. I have also tried this code with the OnCurrent and BeforeUpdate events, with even less success. Thanks for any advice.
Code:
Private Sub type_id_Enter()
If Me.type_id.Value = "PROD" Then
Me.type_id.Locked = True
MsgBox "You cannot edit this type.", vbOKOnly
Else
Me.type_id.Locked = False
End If
If Me.type_id.Value = "LIBR" Then
Me.type_id.Locked = True
MsgBox "You cannot edit this type.", vbOKOnly
Else
Me.type_id.Locked = False
End If
End Sub
Comment