Solved

Esc button problem

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

777 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