I only had the problem when the id_Type was PROD, which is even curioser. I modified the code slightly, placing parts in Form_Current and part in the id_Type.Enter event, and it works fine. I would add a line, at the very beggining, in the Form_Current event, setting the initial focus to another control. It will be very irritating to users, and possibly confusing, to have the message pop up when they move to the record and before they'd done anything. This way it will only chastise them if they deliberately move into the field that has PROD or LIBR in it. It will also help to educate them.
- Private Sub Form_Current()
-
If Me.type_id.Value = "PROD" Or Me.type_id.Value = "LIBR" Then
-
Me.type_id.Locked = True
-
Else
-
Me.type_id.Locked = False
-
End If
-
End Sub
- Private Sub type_id_Enter()
-
If Me.type_id.Value = "PROD" Or Me.type_id.Value = "LIBR" Then
-
MsgBox "You cannot edit this type.", vbOKOnly
-
End If
-
End Sub
Welcome to
Bytes!
Linq
;0)>