Esc button pressed

  • Thread starter Thread starter John Michael
  • Start date Start date
J

John Michael

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
 
John Michael said:
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

Allowing a user to clear a record is not the same thing as controlling when
they can save it. Why don't you want them to be able to undo their changes?
What if they've made such a mess of it that they simply want to start again?

Anyway, you can trap key presses in the form's KeyDown event, and have
Access ignore the ones you are not interested in by setting the KeyCode to
zero.

As for controlling when the record is saved, there are numerous ways in
which a user can save a record: they can close the form, they can go to
another record, they can do it by pressing Shift+Enter, they may be able to
do it from a menu, and so on. To achieve the kind of control you want, you
will need to deal with all of these. You might be able to work out some
kind of grungy lash-up whereby pressing the button sets a value in some
module-level variable, and the form's BeforeUpdate event cancels itself if
that value is not set. Ugh!
 
Answer as to why i would want to do this.
I have 2 command button on the form.
One to save the record and one to cancel.
If you hit cancel and the form is dirty, then any changes or undone with:
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
However, if they changed something and hit the esc key, then the form is no
longer dirty and the acUndo command above sends a message box that says that
the action is not available. I want to test this before time so that the
error is suppresed.

I have a variable that is kept on the form.
VarSessionDirty
I use and set this variable accordingly.


Or is there another way to determine if the form is dirty?
JM
 
John Michael said:
Answer as to why i would want to do this.
I have 2 command button on the form.
One to save the record and one to cancel.
If you hit cancel and the form is dirty, then any changes or undone with:
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
However, if they changed something and hit the esc key, then the form is no
longer dirty and the acUndo command above sends a message box that says that
the action is not available. I want to test this before time so that the
error is suppresed.

I have a variable that is kept on the form.
VarSessionDirty
I use and set this variable accordingly.


Or is there another way to determine if the form is dirty?
JM

If Me.Dirty Then.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top