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
Solved

Esc button problem

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

860 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