Escape from a Form

  • Thread starter Thread starter scs
  • Start date Start date
S

scs

I have a command button open a form and I've added shortcuts to the caption
like &Open. I have been trying to make my database keyboard friendly. Can
I make a form close by pressing escape? How?

Thanks Everyone,
Steve
 
scs wrote in message said:
I have a command button open a form and I've added shortcuts to the caption
like &Open. I have been trying to make my database keyboard friendly. Can I
make a form close by pressing escape? How?

Thanks Everyone,
Steve

If you add a button which closes the form

docmd.close acform, me.name

then in the button properties, set cancel to yes

But - this kind of behaviour is most common for dialog boxes. Be
carefull if you alter behaviour of "known stuff" (or call it "default
behaviour") - you'll soon have users complain;-)
 
Thanks! I guess it would be ok. The forms I want to escape from simply
display information. The user can't edit them.
Are you saying that I shouldn't use this technique for forms that can be
edited since the user would expect different behavior?

Thanks again!
 
scs wrote in message said:
Thanks! I guess it would be ok. The forms I want to escape from simply
display information. The user can't edit them.
Are you saying that I shouldn't use this technique for forms that can be
edited since the user would expect different behavior?

Thanks again!

You'll have to decide what you are going to do ;-)

Joke aside, one will usually reserve such behaviour for dialogs, and
use
a bit more "controlled" approach on data entry forms. I mean something
along the lines of "do you want to close/save" thingies, verifying
valid
data entry ... to avoid accidental closing of the form.
 
Thanks for the advice. I like to do things the "right way". Thanks for
letting me know how.
 
For the most part, I have to agree 100%...

in "ms-access", the escape key does un-do...or "cancel" changes to the field
you are editing (and, hitting esc a 2nd time will cancel changes to the
form).

So, a nice rule is to "follow" the standard conventions of ms-access.

However, I have a lot of older legacy software (FoxPro, and other stuff)
that is green screen.

In virtually all of my older software, Esc actually means to save + close
the form. A nice key...you edit something..and then hit esc to go back a
screen.

over the last few years, I have converted those applications to ms-access,
and thus I STILL have the ESC key = save and close....

Of course, my applications hide all of the ms-access interface, and I ALWAYS
use custom menus. So, for the most part I am somewhat free to choose the
keys sine my end users are NOT ms-access uses...but simply users of *MY* my
application.

So, at the end of day...yes...we should try and leave the ESC to do what it
does by default.

However, you can change this...and if re-writing software that previously
used Esc to exit the screens...then you might want to do the same for those
users of habit.....

You simply set the forms key preview = yes...

and then in the forms keydown event...you go

If KeyCode = vbKeyEscape Then

KeyCode = 0
docmd.Close
End If
 

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

Back
Top