aaabuhalime
Instructor
Hi
I have the following code that enables me to prevent any duplicate entry,I would like to add an other button beside the yes and No, I want to add the option to view the existing record, how can I do this , so the user can determine wether to add or to cancel, I tried the second code for some reson it is not working , Any help will be apprecieted.
Thanks
I have the following code that enables me to prevent any duplicate entry,I would like to add an other button beside the yes and No, I want to add the option to view the existing record, how can I do this , so the user can determine wether to add or to cancel, I tried the second code for some reson it is not working , Any help will be apprecieted.
Thanks
Code:
Private Sub LName_BeforeUpdate(Cancel As Integer)
'If CheckDuplicates(FName,LName) Then
If DCount("FName", "tblCustomers", "FName='" & Me.FName & "' AND LName='" & Me.LName & "'") > 0 Then
Select Case MsgBox("This name already exists" _
& vbCrLf & "Do you want to add this name anyway?" _
, vbYesNo Or vbQuestion Or vbDefaultButton2, "System Duplication Message")
Case vbYes
Case vbNo
Me.Undo
Cancel=True
End Select
End If
End Sub
Code:
Private Sub LName_BeforeUpdate(Cancel As Integer)
Dim strDocName As String
Dim strWhere As String
strDocName = "ContactsSearchScreen"
stWhere = "[FName] = """ & Me.[FName] & """ And [LName]=""" & Me.LName & """"
'If CheckDuplicates(FName,LName) Then
If DCount("FName", "tblContacts", "FName='" & Me.FName & "' AND LName='" & Me.LName & "'") > 0 Then
Select Case MsgBox("This name already exists" _
& vbCrLf & "Do you want to add this name anyway?" _
, vbYesNo Or vbQuestion Or vbDefaultButton2, "System Duplication Message")
Case vbYes
DoCmd.OpenForm strDocName, acPreview, , strWhere
Case vbNo
Me.Undo
Cancel = True
End Select
End If
End Sub