General discussion

Locked

Access 2000 Check for Duplicate Names

By MRA2 ·
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 conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by techrep In reply to Access 2000 Check for Dup ...

Problems like this sometimes occur when you try to access the form's values directly. Try moving the form value into a string variable first:

Dim Lname as string
Lname = Me.[Last Name] & ""
strFind1 = "Last Name = '" & Lname & "'"

Collapse -

by MRA2 In reply to

Thanks for your Help!!!! It worked!!!!

Alan

Collapse -

by MRA2 In reply to Access 2000 Check for Dup ...

This question was closed by the author

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums