Check to see if part number already exists in database
I have a form which the user uses to enter a new part in the database. The following code is supposed to halt the entry if the same part already exists. Note that PART_NO is a text field.
But the code isn't working, the alert pops up even if the part does not exist already.
'Code to check for existing part...
Dim Answer As Variant
Answer = DLookup("[PART_NO]", "tblParts", "[PART_NO] = '" & Me.txtPART_NO & "'")
If Not IsNull(Answer) Then
MsgBox "This part already exists in the database. Please re-enter the details."