I add this to my form to catch duplicate entries. It catches the dupilcate
entries but if I click "No" to "Cancel" it doesn't do anything. I am stuck on
the record unless I click "Yes" Should there be another If Statement in the
code?
**************************** Code********************************************
Private Sub Form_BeforeUpdate(Cancel As Integer)
If DCount("*", "tlkpStaff", "StaffLastName = """ & Me!StaffLastName & """ And
StaffFirstName = """ & Me!StaffFirstName & """") > 0 Then
If MsgBox("There is already a staff member by this name in table. Do
you wish to add it anyway?", vbYesNo) = vbNo Then
Cancel = True
End If
End If
End Sub
Try adding an Undo after the cancel.
Private Sub Form_BeforeUpdate(Cancel As Integer)
If DCount("*", "tlkpStaff", "StaffLastName = """ & Me!StaffLastName & """ And
StaffFirstName = """ & Me!StaffFirstName & """") > 0 Then
If MsgBox("There is already a staff member by this name in table. Do
you wish to add it anyway?", vbYesNo) = vbNo Then
Cancel = True
Me.Undo
End If
End If
End Sub

Signature
_________
Sean Bailey
> I add this to my form to catch duplicate entries. It catches the dupilcate
> entries but if I click "No" to "Cancel" it doesn't do anything. I am stuck on
[quoted text clipped - 11 lines]
> End If
> End Sub
poucedeleon - 28 May 2008 09:54 GMT
Thanks Beetle, That fixed it.
>Try adding an Undo after the cancel.
>
[quoted text clipped - 14 lines]
>> End If
>> End Sub