473,327 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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

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
Aug 24 '16 #1

✓ answered by ADezii

I can't see how the ESC key trigger this private sub?
Make sure the Cancel Property of the Command Button is set to No.

4 1886
ADezii
8,834 Expert 8TB
I can't see how the ESC key trigger this private sub?
Make sure the Cancel Property of the Command Button is set to No.
Aug 24 '16 #2
Thank You ADezii for the quick response . It helped a lot.
But please , I still do not understand the link between the Esc key and the Click event which should be the only trigger
of private sub( cmdCancelRecord_Click() ?
Thank you .
Aug 24 '16 #3
ADezii , Thanks . I thought again about what you've suggested .
Now , everything is clear .the Cancel Property of the Command Button has a built-in link to the Esc key in the keyboard. I take my question back .
Thank You very much.
Aug 24 '16 #4
ADezii
8,834 Expert 8TB
You're welcome. There can only be a single Command Button set to Cancel = True. If you set this Property = Yes for a Command Button, all others are automatically set to No. When the ESC Key is pressed, Code in the Click() Event of this Button is executed. You never stated if this was actually the problem, was it?
Aug 25 '16 #5

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

Similar topics

11
by: raulgz | last post by:
I need audit triggers that change columns value in the same record that fire trigger. I need how to do.. Thanks..
19
by: qazmlp | last post by:
class base { // other members public: virtual ~base() { } virtual void virtualMethod1()=0 ; virtual void virtualMethod2()=0 ; virtual void virtualMethod3()=0 ;
1
by: Michael | last post by:
I want to insert a row into an ITEM table if certain SKUs are inserted. There are two triggers where each looks for a particular SKU and inserts the appropriate matching row in the same table. ...
1
by: baby ell | last post by:
I'm accessing a private queue in another machine and if the queue does not exists in that machine, i would like to create the private queue. Example: MessageQueue newmsg =...
2
by: cefrancke | last post by:
I have a datagrid on a windows form with a bindingnavigator. The tableadapter, bindingsource and dataset are there also. I can browse and edit data normally. I had added the "click" event...
5
by: james.jdunne | last post by:
System.ArgumentException: Item has already been added. Key in dictionary: "-1" Key being added: "-1" at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at...
0
by: vinothg | last post by:
Just thought of posting this example about private interface which i learned from bruce eckel book "Thinking in Java" An interface can be nested within a class or another interface. If the...
0
debasisdas
by: debasisdas | last post by:
This thread contains some useful tips/sample codes regarding TRIGGERS in oracle, that the forum members may find useful. TRIGGERS: =============== Database trigger is a PL/SQL block that is...
1
jackb
by: jackb | last post by:
Structure of my application is: 1. Message is dispatched to an application 2. That application puts the message in a private queue 3. Another application reads messages from this queue and...
0
by: Tim Davis | last post by:
SIP SMS Example The importance of SIP messages is great because often they are used for various purposes. They are for establishing phone calls, making complementary actions etc. Today when we...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.