custom error popup for duplicate records???

Zako

Registered User.
Local time
Yesterday, 21:04
Joined
Apr 20, 2003
Messages
18
I need to make a custom message in my access database when someone tries to make a duplicate record.
My table detects duplicates based on a phone number field called "fldPrimPhone"
I would like to have a message other than the long winded default MS Access one appear when someone tries to enter a new record with a phone number that is already in the database.

How can I make a message like this?
 
If you validate the users input in either the Forms or the Controls Before Update event you can pop up a message using MsgBox to tell the user what they did wrong. Place the cursor in the Before Update event and press F1 for some basic code to validate the input.

hth,
Jack
 
Heres a code that I use to check for a duplicate record. If it finds an that No. a message pops up. Its simple but effective.

Just change the names to your control names.

Private Sub SSNNo_BeforeUpdate(Cancel As Integer)
If DCount("[SSNNo]", "tblreferrals", "[SSNNo]='" & Me.SSNNo & "'") Then
MsgBox "This SSN Number already exists!!" & _
vbCrLf & " This SSN already has been assigned. Do a ", _
vbOKOnly, "Duplicated entry"
Cancel = True
Me.Undo
Exit Sub
Else 'Do nothing
End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom