(Solved) – Warning for Duplicate Entry in MS Access still pop out even it’s not duplicate

(solved)-–-warning-for-duplicate-entry-in-ms-access-still-pop-out-even-it’s-not-duplicate

I create a VBA Code in MS Access entry form to restrict duplicate entry of request number.
it throws the warning when I enter duplicate value, my problem is that, it keeps on throwing warning even if I enter unique one.

Please help me check what is wrong with my code below.

Private Sub Request_Number_AfterUpdate()

Dim Request_Number As String
Dim Answer As Variant

Answer = DLookup("[Request Number]", "GSAPAssets", "[Request Number] ='" & Me.Request_Number & "'")
If Not IsNull(Answer) Then
MsgBox "Req Number Already in use.", vbInformation, "Duplicate Details."
Me.Request_Number = ""
Cancel = True
Me.Request_Number.SetFocus


Else:
End If

End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *