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?