473,508 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How could the ESC key triggers private sub( cmdCancelRecord_Click()-for example)

12 New Member
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
Last edited by Don Quixote; 5 Minutes Ago at 10:57 PM. Reason: I forgot to mention it as Access VBA question
Aug 24 '16 #1
1 734
ADezii
8,834 Recognized Expert Expert
Make sure the Cancel Property of the Command Button is set to No.
Aug 24 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
4069
by: Terry | last post by:
The following code (VB6) automatically sets ticks or null values for Check Boxes: 'Pass' and/or 'Resit', depending on the data entered in the 'ModuleID' and 'Mark' Text Boxes. 'ModuleID' is a...
3
5234
by: Venkat Venkataramanan | last post by:
Hello: I have a winform that has a private subroutine defined as: Private Sub ApplyFilter() This sub refers to objects that get instantiated in the winform's new method. However, when I...
3
4203
by: Gene Hubert | last post by:
I'm using DataTable.ImportRow to move data from one datatable to another... Dim dt, dtTarget As DataTable Dim dr As DataRow dt = DirectCast(Me.DataSource, DataTable) dtTarget = dt.Clone...
6
2001
by: squrel | last post by:
HI.. I need help over here... i have a delete button but is giving me error as " operation is not allowed when the object is closed" Can anyone help me here, plz thanks a lot Private Sub...
4
3413
by: Reg9 | last post by:
Private Sub cmdProcessEvents_Click() strEventID = "Audit0001" 'This works: Audit0001 'These do not: Eval (strEventID) ...
4
2164
by: gayatri mahajan | last post by:
Private Sub mnudipositrpt_Click() 'Set rptDeposits.DataSource = Nothing 'Set rptDeposits.DataSource = rsDeposit 'rptDeposits.Show End Sub Private Sub mnufd_Click() Main.Toolbar1.Visible =...
4
2701
by: Dixie | last post by:
How do I make this work for VB- Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NameBox.TextChanged
1
1745
by: rklass | last post by:
I'm trying to do a dlookup and I keep getting an error. I have a table (Supplier_List) with the "Supplier_ID" and the "Supplier_Name". I have another table that I'm using on my form (“Item Table”...
1
3278
by: jharding | last post by:
Hi, I am currently working on a form that will be used to update a table (tblAuditableEntitiesHistory). I have two private sub procedures that will need to be merged so that the table fields and...
0
7233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7342
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7410
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7067
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5650
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.