I have built a datasheet subform that holds user login information. I added validation to ensure that a user cannot be entered twice (code follows).
My problem is that now I can't seem to edit the records because of my validation code. Any thoughts on how I can do this?
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim varCheck As Variant
varCheck = DLookup("[ClientID]", "tblUserInfo", "[ClientID]= " & Me!ClientID & "")
If IsNull(varCheck) Then
Exit Sub
Else
MsgBox ("The client is already in the system.")
DoCmd.CancelEvent
Me.ClientID.SetFocus
End If
End Sub
My problem is that now I can't seem to edit the records because of my validation code. Any thoughts on how I can do this?
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim varCheck As Variant
varCheck = DLookup("[ClientID]", "tblUserInfo", "[ClientID]= " & Me!ClientID & "")
If IsNull(varCheck) Then
Exit Sub
Else
MsgBox ("The client is already in the system.")
DoCmd.CancelEvent
Me.ClientID.SetFocus
End If
End Sub