Below is my code. Me.Confirmed is a checkbox. Sometimes the cancel at line 37 works when the user clicks "no", someetimes it doesn't.
Is this my fault or someting else?
Is this my fault or someting else?
Code:
Private Sub Confirmed_BeforeUpdate(Cancel As Integer)
If gcfHandleErrors Then On Error GoTo PROC_ERR
PushCallStack "ConfirmDeployment"
Dim strfield As String
strfield = Me.ConsultantID & ""
If StrPtr(strfield) = 0 Or Len(strfield) = 0 Then
MsgBox "Cannot confirm deployment as no Consultant has been selected", vbCritical, "title"
Me.Undo
Cancel = True
GoTo PROC_EXIT
End If
Dim Msg1, Style1, Title1, Response1
If Me.Confirmed = True Then
Msg1 = "Are you sure that you want to confirm deployment of consultant to this Job?"
Msg1 = Msg1 & vbCrLf & "Make sure this is what you want to do."
End If
If Me.Confirmed = False Then
Msg1 = "Are you sure that you want to cancel deployment of consultant to this Job?"
Msg1 = Msg1 & vbCrLf & "Make sure this is what you want to do."
End If
Style1 = vbYesNo + vbQuestion + vbDefaultButton2
Title1 = "Confirm "
Response1 = MsgBox(Msg1, Style1, Title1)
If Response1 = vbYes Then
GoTo PROC_EXIT
Else
Me.Undo
Cancel = True
GoTo PROC_EXIT
End If
PROC_EXIT:
PopCallStack
Exit Sub
PROC_ERR:
GlobalErrHandler
Resume PROC_EXIT
End Sub
Comment