I've been attempting to have a field within a form check whether or not a duplicate record exists and deliver a message immediately after you navigate away from the field. I'm uncertain whether the code I have is what I really need, it's the only code so far however that's produced something close to what I'd like, unfortunately it seems to think every record entered is a duplicate one. I'm sure there is an obvious error in my method, but I know virtually nothing about VB, can anyone point me straight???
Code:
Private Sub YC_TAG_BeforeUpdate(Cancel As Integer)
Dim YC_TAG As Integer
YC_TAG = DCount("[YC_TAG]", "Assets", "[YC_TAG] =" & Me.YC_TAG)
If YC_TAG > 0 Then
MsgBox "Duplicate Present", vbOKOnly
Cancel = True
Exit Sub
End If
End Sub