I have used this code in Access 97 databases and it works! It checks the lastname and first name. If both are identical you get an error message.
I copied and pasted it into Access 2000 and I keep getting an error message.
Error: Syntax Error(Missing Operator) in expression
on the line: rst.FindFirst strFind1
The code I am using is:
‘Routine to check for Duplicate Name when entering NEW Name
Dim rst As Recordset
Dim db As Database
Dim strFind1 As String
Dim strFind2 As String
Set rst = Me.RecordsetClone
strFind1 = “Last Name = ‘” & Me.[Last Name] & “‘”
strFind2 = “First Name = ‘” & Me.[First Name] & “‘”
rst.FindFirst strFind1
rst.FindFirst strFind2
If Not rst.NoMatch Then
MsgBox ” DUPLICATE!!!!!!!!!”
Me.Undo
Else
MsgBox “NO DUPLICATE FOUND!!!!”
End If
End Sub