Access 2000 Check for Duplicate Names - TechRepublic
General discussion
November 12, 2003 at 10:11 AM
mra2

Access 2000 Check for Duplicate Names

by mra2 . Updated 22 years, 7 months ago

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

This discussion is locked

All Comments