473,569 Members | 2,704 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Esc button pressed

Is it possible to detect when someone has pushed their Esc button on a form.

When a form is open and someone is adding a record, if they push the esc
button, the whole form gets reset to an empty record.

Is it possible to detect or can you disable this so that the record does not
clear?

I know there is an On Dirty event for forms, but are there any events that
will tell me if the form has changed from dirty to clean?

I'm trying to create forms that don't update or add new records until they
push the command button when they are finished.
Is it possible to not have it commit until you trigger an event from a
command button?

Thanks
JM
Nov 13 '05 #1
1 7194
To prevent Esc, you can turn on the form's KeyPreview property, and then use
the KeyDown event to destroy the keystroke if the KeyCode is 27, i.e.:
If KeyCode = 27 Then
KeyCode = 0
End If

The only way to prevent the record updating is to cancel the Before Update
event of the form, because there are so many ways a record can be saved,
e.g. cycle through controls, move record, filter, change the sort, alter
recordsource, close the form, close Access, press Shift+Enter, choose Save
Record from the Record menu, and so on. So if you want to insist that no
save can take place except through your button, you will need to declare a
module-level boolean variable:
Dim mbAllowSave As Boolean
set it to True in the Click event of your command button before the save:
mbAllowSave = True
Me.Dirty = False
and cancel Form_BeforeUpda te if the variable has not been set:
If Not mbAllowSave Then
Cancel = True
MsgBox "No save without button click!"
End If
mbAllowSave = False

You now have the user in a straightjacket, and if they know anything about
Access, they will hate you for it. What was the reason that you wanted to
stop the user from access all the good functionality built into Access? IME,
most people who do this do so because they don not understand how to handle
the events that Access exposes to you, and think procedureally instead of
event-driven.

For an introduction to event-driven programming, see:
http://members.iinet.net.au/~allenbrowne/xbase-02.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John Michael" <jo***@acadiaco m.net> wrote in message
news:10******** *****@corp.supe rnews.com...
Is it possible to detect when someone has pushed their Esc button on a
form.

When a form is open and someone is adding a record, if they push the esc
button, the whole form gets reset to an empty record.

Is it possible to detect or can you disable this so that the record does
not clear?

I know there is an On Dirty event for forms, but are there any events that
will tell me if the form has changed from dirty to clean?

I'm trying to create forms that don't update or add new records until they
push the command button when they are finished.
Is it possible to not have it commit until you trigger an event from a
command button?

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2826
by: robert | last post by:
hi! I want to have a custom button change appearance when pressed and then call a function and change back to its original appearance when released. here's what i have now, which works mostly. "drop" is my handler for the button, its argument tells me which button was pressed. i have a number of these buttons and they are organized in a...
2
41039
by: jb | last post by:
Hello, I need to know which button was pressed in the submit , i tried reading the vaule of submit it the validateDate function but it returns 'undefined' value ; I do this in asp all the time, Not sure how to do it in javascript <form name="form1" method="post" action="myNewplace.asp" ONSUBMIT="return ValidateData();"> <input...
8
14634
by: Syed Ali | last post by:
Hello, I have 1 HTML form with 4 submit buttons and 10 textfield entry areas. If submit button1 is pressed I need to make sure that all 10 textfield entries have been filled before submitting the form. If submit button2 is pressed I need to make sure that only textfied1 is filled before submitting the form.
3
1953
by: James McGivney | last post by:
I have a project in VS.NET using C# I have a series of buttons on an aspx page. When one of the buttons is pressed, a panel becomes visible and allows the user to enter and edit data. I want to use this data to modify the text of the button I am thinking of storing a unique identifier in View State when the button is pressed. After the user...
18
3045
by: jrhoads23 | last post by:
Hello, I am trying to find a way to tell if an .NET windows forms Button (System.Windows.Forms.Button) is "depressed" (pushed down). For my application, I can not use a check box control set to button style, I must use a System.Windows.Forms.Button. I can not find a way to tell when it is momentaraly pressed. I tried calling the API...
7
1828
by: Miguel Dias Moura | last post by:
Hello, I am working in ASP.net / VB with Access Database. i have a Multipage in my web site with the Submit button as the last button. When the Submit button is pressed i want the form values to be added to a database and sent by email. 1. I have the code which submits the form values to the database. (See at
7
16018
by: Amadelle | last post by:
Hi all and thanks in advance, I am stuck! I can't figure out how to identify which button was clicked on my ASP.NET page in the PostBack event? So what I am trying to do is to is to have an if statement like as follows in the PageLoad: private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { //do something...
2
2791
by: Krista Lemieux | last post by:
Hello, In my form I have a button, and the button_Click function (which gets called when the button is clicked). However the functionality that I have in the button_Click function, needs to be in the Page_Load, since I need to change a value based on the button click to render the page. So my question is, can I access the button object...
19
2167
by: darrel | last post by:
On my vb.net page, I have 4 sets of inputs + form buttons. example: Search: (GO) Zip: (GO) County: (GO) County: (GO) The problem is if I go to the page, type in a zip code, and hit enter.
3
1747
by: noddy | last post by:
I have a button <input type="button" value="Get data"> When it is clicked a database is accessed and the data is eventually displayed on the screen. While the data is being retrieved the button is displayed in its "pressed in" state. When the data arrives and is displayed the button pops out to its normal "unpressed" state.
0
7698
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7673
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.