Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture 'Esc' or X (close)

Status
Not open for further replies.

Nunina

Programmer
Mar 5, 2003
128
PR
Hi Guys!

I need to capture when a user presses the ESC key to close a form or when they use their mouse by pressing the X button. Automatically it goes into the Unload event without capturing which was pressed (Esc or mouse).

Can any of you help??

Thanks a lot!! [sunshine]

[gorgeous] Nunina
 

Look at the KeyPress event

Private Sub Form_KeyPress(KeyAscii As Integer)
'Capture the esc key here

End Sub


Look at the Query_Unload for your form as well


Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

'Trap the start of exit here (when user clicks 'x'

End Sub
 
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

if UnloadMode = 0 then
'they clicked the cross
if UnloadMode = 1 Then
'they pressed Esc

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Thanks a lot, guys!!!!!

Have a great weekend!!!


Nunina
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top