UserForm Keyboard Control

  • Thread starter Thread starter DoctorG
  • Start date Start date
D

DoctorG

I am new in Forms design. Can anyone tell me how to activate or specify the
use of Enter and Esc keys in a form so that they represent a positive and a
negative user choice?
 
For the CommandButton that you want "clicked" when the Enter key is
pressed... set its Default property to True.

For the CommandButton that you want "clicked" when the Esc key is pressed...
set its Cancel property to True.
 
Hi Rick!

Thanks for the feedback.

Can you tell me how to trap the red "X" on the top-right corner of the form?
Is it the same as the default Cancel key?
 
You would "trap" the red X by using, depending on your needs, either the
QueryClose or Terminate event procedures for the UserForm (in the UserForm's
code window, select UserForm from the left-hand drop down and QueryClose or
Terminate from the right-hand drop down). The QueryClose event gives you the
ability to cancel the closing of the UserForm if desired via its Cancel
argument.
 
Back
Top