P
poucedeleon via AccessMonster.com
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
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