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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with AutoKeys macro (ESC key)

Status
Not open for further replies.

Jaco

Programmer
Aug 29, 2000
57
PL
Hello.
I have a problem with adding an ESC key to AutoKeys. I tried to add it like this: {ESC} but it doesn't work and I don't understand why.

Please help.

Jaco, Poland [sig][/sig]
 
Hi Jaco,

well sorry i've only ever used one macro autoexec in access ver 2, but i've checked the help file and {esc} is correct but is access expecting to get a esc at the point your using it?? and can you use code to do what you want??

see ya
Robert [sig][/sig]
 
No I want only to define a shortcut. Esc key should close a form. Does anyone know a better way?

Thanks for any help. [sig][/sig]
 
Hi Jaco

try

for the form set the "events" tab set the Key Preview to yes

add this to the code module and the "Esc" key will close the form.


Private Sub Form_KeyPress(KeyAscii As Integer)

If KeyAscii = 27 Then
DoCmd.Close
End If

End Sub

the "Esc" key is also used by access to undo an edit another approch is to add a command button to the form set the caption to E&xit this will allow the user to use the key combination "Alt" "x" to close the form. i usually use
E&xit as it's more in line with windows

Private Sub ClsFrm_Click()

On Error GoTo Err_ClsFrm_Click
' close this form
DoCmd.Close
Exit_ClsFrm_Click:
Exit Sub
Err_ClsFrm_Click:
MsgBox Err.Description
Resume Exit_ClsFrm_Click
End Sub

HTH
Robert [sig][/sig]
 
It works. Thanks.

Jaco [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top