Duplicate Record Error Check

G

Guest

Can I check for duplicate records and display an error message immediately
after entry of a CustID number? I would think somthing like this in the
AfterUpdate event would do it, but no luck.

If DataErr = 3022 Then
MsgBox "Duplicates not allowed"
End If
 
G

Guest

This is typically done in the control's Before Update event:

If Not IsNull(DLookup("[CustID]", "CustomerTable", "[CustID] = " &
Me.txtCustID)) Then
MsgBox "Customer " & Me.txtCustID & " is already in the table"
Cancel = 0
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top