cstuckey56
Registered User.
- Local time
- Today, 09:32
- Joined
- Feb 21, 2008
- Messages
- 13
I see this question is asked a number of time but I tried to use the code that is suggested but it doesn't work. Can someone please give me advise on the proper code to prevent duplicate records in my form?
I'm using:
Private Sub Ctl_Lname_BeforeUpdate(Cancel As Integer)
Dim dupCount As Long
dupCount = DCount("*", "Clients", "[LastName]= '" & Me.[LastName] & "'" & " And " & "[PreferredName] = '" & Me.[PreferredName] & "'")
If dupCount <> 0 Then
Beep
MsgBox "This name already exists in the database. Please check that you are not entering a duplicate person before continuing.", vbOKOnly, "Duplicate Value"
Cancel = True
End If
End Sub
Table = "Clients"
Field1 = "LastNeme"
Field2 = "PreferredName"
Thanks
Chris
I'm using:
Private Sub Ctl_Lname_BeforeUpdate(Cancel As Integer)
Dim dupCount As Long
dupCount = DCount("*", "Clients", "[LastName]= '" & Me.[LastName] & "'" & " And " & "[PreferredName] = '" & Me.[PreferredName] & "'")
If dupCount <> 0 Then
Beep
MsgBox "This name already exists in the database. Please check that you are not entering a duplicate person before continuing.", vbOKOnly, "Duplicate Value"
Cancel = True
End If
End Sub
Table = "Clients"
Field1 = "LastNeme"
Field2 = "PreferredName"
Thanks
Chris