Visually, it's intuitive. Record 1 and 2 are not duplicates. So what did I do wrong in the code? Or should I place the code on a different triggering event?
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim ClickResult As VbMsgBoxResultEx
'Make sure there is some value in the field. If not, remove the blank cell.
If Nz(Me.Certification_ID, "") = "" Then
Me.Undo
Exit Sub
ElseIf DCount("*", "[t_Contacts_Certification_Relationship]", "[Name_ID]= " & Me.[Name_ID] & " And [Certification_ID]= " & Me.[Certification_ID] & " And [Certication_Level_ID]= " & Nz(Me.[Certication_Level_ID], 0)) > 0 Then
ClickResult = Dialog.RichBox("This is a duplicate record. " & "</p>" & _
"Click OK to remove it.", vbOKOnly + vbCritical, "Duplicate Entry", , , 0, False, False, False)
If ClickResult = vbOK Then
Me.Undo
End If
End If
End Sub