S
SA2002
I am using the below code to check for duplicate records between three email
fields. Is there a way to add a message box so that when a person enters a
duplicate email address in any of the fields (email1, email2, email3) that a
msg box will pop up?
Private Sub txtEmail1_BeforeUpdate(Cancel As Integer)
If Duplicated Then DoCmd.CancelEvent
End Sub
Private Sub txtEmail2_BeforeUpdate(Cancel As Integer)
If Duplicated Then DoCmd.CancelEvent
End Sub
Private Sub txtEmail3_BeforeUpdate(Cancel As Integer)
If Duplicated Then DoCmd.CancelEvent
End Sub
Private Function Duplicated() As Boolean
Dim EM1, EM2, EM3 As String
EM1 = Nz(txtEmail1, "NoEmail1")
EM2 = Nz(txtEmail2, "NoEmail2")
EM3 = Nz(txtEmail3, "NoEmail3")
If EM1 = EM2 Or EM2 = EM3 Or EM3 = EM1 Then
Duplicated = True
Else
Duplicated = False
End If
End Function
fields. Is there a way to add a message box so that when a person enters a
duplicate email address in any of the fields (email1, email2, email3) that a
msg box will pop up?
Private Sub txtEmail1_BeforeUpdate(Cancel As Integer)
If Duplicated Then DoCmd.CancelEvent
End Sub
Private Sub txtEmail2_BeforeUpdate(Cancel As Integer)
If Duplicated Then DoCmd.CancelEvent
End Sub
Private Sub txtEmail3_BeforeUpdate(Cancel As Integer)
If Duplicated Then DoCmd.CancelEvent
End Sub
Private Function Duplicated() As Boolean
Dim EM1, EM2, EM3 As String
EM1 = Nz(txtEmail1, "NoEmail1")
EM2 = Nz(txtEmail2, "NoEmail2")
EM3 = Nz(txtEmail3, "NoEmail3")
If EM1 = EM2 Or EM2 = EM3 Or EM3 = EM1 Then
Duplicated = True
Else
Duplicated = False
End If
End Function