working hotkey even if any control has focus in userform

  • Thread starter Thread starter x taol
  • Start date Start date
X

x taol

i want to close the userform if press the esc key.
Current, the userform have many controls.

in that case, even if any control has focus, i want to close the
userform when the esc key pressed.
 
Add a button to the form, and code like so

Private cmdEsc_Click()
Unload Me
End Sub

and set the Cancel property of that button to True

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
thanks bob.
then, I will automate your source code.

Private cmdEsc_Click()
Unload Me
End Sub

my source code follow.
with me.controls.add("forms.commandbutton.1")
Left = 10
Top = 10
Width = 0
Height = 0
Cancel = True
End With
and then i don't know
 
Don't add the button dynamically, add it at design.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Back
Top