Solved

Esc button problem

Posted on 1998-12-15
5
568 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
  • 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now