crisis2007
Technical User
I have the following code on a command button. I want to check for duplicate values before closing the form. It works fine if there are duplicate values and the message box pops up properly and both the yes and no buttons work. However if there are no duplicate values, the form does not close. I can see I have an issue in the code but can not find where I need to place a statement in order to close the form if no duplicates are found:
Private Sub Command14_Click()
Dim Response As Long
Dim numActivity As Integer
numActivity = 0
numActivity = DCount("*", "Q_NameRepeatEditForm_N")
If numActivity > 1 Then
Response = MsgBox("FYI: You have an employee listed twice in your roster. Do you want that?" & _
vbCrLf & _
vbCrLf & "If 'Yes', this form will then close." & _
vbCrLf & "If 'No', then you can go back and change that.", vbYesNo + vbQuestion, "Is That What You Want?")
If Response = vbYes Then
DoCmd.Close
End If
End If
Exit_Command14_Click:
Exit Sub
Err_Command14_Click:
MsgBox Err.Description
Resume Exit_Command14_Click
End Sub
Private Sub Command14_Click()
Dim Response As Long
Dim numActivity As Integer
numActivity = 0
numActivity = DCount("*", "Q_NameRepeatEditForm_N")
If numActivity > 1 Then
Response = MsgBox("FYI: You have an employee listed twice in your roster. Do you want that?" & _
vbCrLf & _
vbCrLf & "If 'Yes', this form will then close." & _
vbCrLf & "If 'No', then you can go back and change that.", vbYesNo + vbQuestion, "Is That What You Want?")
If Response = vbYes Then
DoCmd.Close
End If
End If
Exit_Command14_Click:
Exit Sub
Err_Command14_Click:
MsgBox Err.Description
Resume Exit_Command14_Click
End Sub