Hey all,
When I run my code I get error 20 when I enter a correct answer. I am not sure why it's not working but I assume it is because I have multiple exit sub commands. Any advice here?
Exit Sub
ErrHandler:
Dim AnswerErr As Integer
ErrCount = ErrCount + 1
DataMonth = Application.InputBox _
("Please enter the closest date that resembles " & _
DataMonth & _
", in format (Mm/01/Yyyy)", "Invalid Date Format!")
'Easter Egg
If ErrCount = 4 Then
MsgBox "I've just picked up a fault in the AE35 unit. It's going to go 100% failure in 72 hours Dave. ", vbCritical, "HAL"
DataMonth = Application.InputBox _
("Please enter the closest date that resembles " & _
DataMonth & _
", in format (Mm/01/Yyyy)", "Invalid Date Format!")
If DataMonth = False Then
AnswerErr = MsgBox("Are you sure you don't want to enter a data month? LinkUp Eligibility will not be calculated!", vbYesNo, "Cancel Clicked")
If AnswerErr = 6 Then
DataMonth = ""
Exit Sub
Else
GoTo ErrHandler
End If
Else
GoTo ErrHandler
End If
ElseIf ErrCount = 9 Then
MsgBox "Just what do you think you're doing, Dave? ", vbCritical, "HAL"
DataMonth = Application.InputBox _
("Please enter the closest date that resembles " & _
DataMonth & _
", in format (Mm/01/Yyyy)", "Invalid Date Format!")
If DataMonth = False Then
Answer = MsgBox("Are you sure you don't want to enter a data month? LinkUp Eligibility will not be calculated!", vbYesNo, "Cancel Clicked")
If Answer = 6 Then
DataMonth = ""
Exit Sub
Else
GoTo ErrHandler
End If
Else
On Error GoTo ErrHandler
End If
ElseIf ErrCount = 14 Then
MsgBox "Cake, and grief counseling, will be available at the conclusion of the test. ", vbExclamation, "GLaDOS"
DataMonth = Application.InputBox _
("Please enter the closest date that resembles " & _
DataMonth & _
", in format (Mm/01/Yyyy)", "Invalid Date Format!")
If DataMonth = False Then
Answer = MsgBox("Are you sure you don't want to enter a data month? LinkUp Eligibility will not be calculated!", vbYesNo, "Cancel Clicked")
If Answer = 6 Then
DataMonth = ""
Exit Sub
Else
GoTo ErrHandler
End If
Else
On Error GoTo ErrHandler
End If
ElseIf DataMonth = False Then
Answer = MsgBox("Are you sure you don't want to enter a data month? LinkUp Eligibility will not be calculated!", vbYesNo, "Cancel Clicked")
If Answer = 6 Then
DataMonth = ""
Exit Sub
Else
GoTo ErrHandler
End If
End If
Resume
End Sub
When I run my code I get error 20 when I enter a correct answer. I am not sure why it's not working but I assume it is because I have multiple exit sub commands. Any advice here?
Exit Sub
ErrHandler:
Dim AnswerErr As Integer
ErrCount = ErrCount + 1
DataMonth = Application.InputBox _
("Please enter the closest date that resembles " & _
DataMonth & _
", in format (Mm/01/Yyyy)", "Invalid Date Format!")
'Easter Egg
If ErrCount = 4 Then
MsgBox "I've just picked up a fault in the AE35 unit. It's going to go 100% failure in 72 hours Dave. ", vbCritical, "HAL"
DataMonth = Application.InputBox _
("Please enter the closest date that resembles " & _
DataMonth & _
", in format (Mm/01/Yyyy)", "Invalid Date Format!")
If DataMonth = False Then
AnswerErr = MsgBox("Are you sure you don't want to enter a data month? LinkUp Eligibility will not be calculated!", vbYesNo, "Cancel Clicked")
If AnswerErr = 6 Then
DataMonth = ""
Exit Sub
Else
GoTo ErrHandler
End If
Else
GoTo ErrHandler
End If
ElseIf ErrCount = 9 Then
MsgBox "Just what do you think you're doing, Dave? ", vbCritical, "HAL"
DataMonth = Application.InputBox _
("Please enter the closest date that resembles " & _
DataMonth & _
", in format (Mm/01/Yyyy)", "Invalid Date Format!")
If DataMonth = False Then
Answer = MsgBox("Are you sure you don't want to enter a data month? LinkUp Eligibility will not be calculated!", vbYesNo, "Cancel Clicked")
If Answer = 6 Then
DataMonth = ""
Exit Sub
Else
GoTo ErrHandler
End If
Else
On Error GoTo ErrHandler
End If
ElseIf ErrCount = 14 Then
MsgBox "Cake, and grief counseling, will be available at the conclusion of the test. ", vbExclamation, "GLaDOS"
DataMonth = Application.InputBox _
("Please enter the closest date that resembles " & _
DataMonth & _
", in format (Mm/01/Yyyy)", "Invalid Date Format!")
If DataMonth = False Then
Answer = MsgBox("Are you sure you don't want to enter a data month? LinkUp Eligibility will not be calculated!", vbYesNo, "Cancel Clicked")
If Answer = 6 Then
DataMonth = ""
Exit Sub
Else
GoTo ErrHandler
End If
Else
On Error GoTo ErrHandler
End If
ElseIf DataMonth = False Then
Answer = MsgBox("Are you sure you don't want to enter a data month? LinkUp Eligibility will not be calculated!", vbYesNo, "Cancel Clicked")
If Answer = 6 Then
DataMonth = ""
Exit Sub
Else
GoTo ErrHandler
End If
End If
Resume
End Sub