Lookup Duplicate data in selected fields

karatelung

Registered User.
Local time
Today, 12:28
Joined
Apr 5, 2001
Messages
84
I need a message box to pop up whenever a user enters a duplicate entry - three particular fields. Duplicate entries are allowed, but usually it's a mistake.

The fields are FirstName, LastName, and Client from tblDemographics. The form is frmDemographics. I assume that the code would go in the AfterUpdate event of the third field - Client.

Help is greatly appreciated.
 
I would put the code on the AfterInsert event - after the record is recorded.

The code might look something like this:
Code:
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblDemographics", dbOpenDynaset)

rs.FindFirst "[FirstName] = '" & Me.FirstNameControl & "' AND [LastName] = '" & Me.LastNameControl & "' AND [Client] = '" & Me.ClientControl & "'"

If rs.NoMatch Then Exit Sub

MsgBox "You have duplicate data!"

HTH
 
Thanks.

I'll try it out as soon as I get our DSL and DHCP Server problems worked out.
 

Users who are viewing this thread

Back
Top Bottom