View Full Version : Lookup Duplicate data in selected fields


karatelung
10-05-2001, 06:28 AM
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.

shacket
10-05-2001, 11:25 AM
I would put the code on the AfterInsert event - after the record is recorded.

The code might look something like this:

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

karatelung
10-10-2001, 05:25 AM
Thanks.

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