I have a form of an Access database that has a navigation buttons (next, previous, first, last)
and command buttons as well (SaveRecord, CancelRecord , etc).
The procedure behind the CancelRecord button is :
[Private Sub cmdCancelRecord_Click()
Dim Response As VbMsgBoxResult
Response = MsgBox("you cancel the update " & vbNewLine & " The form will be closed without saving updates? ", vbCritical Or vbYesNo)
If Response = vbYes Then
Me.Undo
CloseForm ' Send to another sub
End If
End Sub]
Also I have an event-procedure in this form :
[Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
If Not blnOK Then ' Boolean variable to determine whether or not the user click the SaveRecord button
Cancel = True
strMsg = "Click the SaveRcord button to save the updates & vbNewLine & "or Esc key to cancel them"
MsgBox strMsg, vbOKOnly, "Before Update"
End If
End Sub]
Now , when the user try to move to the next record after making any changes in the record ,
(The BeforeUpdate event is triggered )and then when the user press the Esc key as he has Prompted by the message box – the control is passed to cmdCancelRecord_Click() procedure .
I can't see how the ESC key trigger this private sub?
I thought it should cancel the updates without passing the control to CancelRecord procedure.
Thanks in advance