Solved

Esc button problem

Posted on 1998-12-15
5
586 Views
Last Modified: 2008-02-26
Hi Experts,

I want to use something like this in the form
KeyDown event:

If KeyCode = vbEsc Then
MsgBox "It works!"
End if


But this is not enought
Dim KeyCode as ?????

I dont know, please help me....
0
Comment
Question by:Booty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
Trygve earned 0 total points
ID: 1971153
A small error in the ESC-constant. Try this

    If KeyCode = vbKeyEscape Then
        MsgBox ("It works !")
    End If

It worked in my test application. Have a look in the help file for Keycode Constants for other usefull constants.

Trygve
0
 

Author Comment

by:Booty
ID: 1971154
Hi Trygve,
It worked fine but how do I use this
in the KeyPress event ?

Error at the word KeyCode...

Regards
0
 
LVL 12

Expert Comment

by:Trygve
ID: 1971155
Can't you use the KeyDown event ? That was what you asked for...

For KeyPressed event:

    If KeyAscii = vbKeyEscape Then
        MsgBox ("Hei")
    End If


From help: "To make sure a form receives all keyboard events, even those that occur for controls, before they occur for the controls, set the KeyPreview property of the form to Yes."


Generally: Look at the parameters in the sub header and read the help file for examples on how to use the functions, events etc.
0
 

Author Comment

by:Booty
ID: 1971156
Hi Trygve,

Yes I asked for KeyDown and then for
KeyPress .
Two answers for 5 points...sorry :-)

Thanks.
0
 
LVL 12

Expert Comment

by:Trygve
ID: 1971157
No problem !

Have a nice day !
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question