Solved

Hotkey independent of what has the control focus

Posted on 2004-08-04
3
276 Views
Last Modified: 2010-05-18
I need to know how to have a hot key execute a sub routine or function regardless of what control has the focus. Functionally, what I want is very similar to when you assign CTRL-N to a menu.

The software is a point of sale system, and I need the user to be able to press "c" and have the credit card dialog pop up, or the "t" key and have the "tender bill" dialog come up.

Any thoughts?
0
Comment
Question by:DrDamnit
3 Comments
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 500 total points
ID: 11723170
You can use HotKey (an example of mine below):
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/VB_Controls/Q_21047290.html

..or just do it through form-level. A form's KeyPreview property allows keydown events to be passed to the form even if another control has focus.

Example:
-------------
Option Explicit
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF1 Then
        Call MsgBox("F1 was pressed.")
    End If
End Sub
Private Sub Form_Load()
    Me.KeyPreview = True
End Sub
0
 
LVL 5

Expert Comment

by:cristy56
ID: 11723176
0
 
LVL 32

Author Comment

by:DrDamnit
ID: 11730723
Keypreview did it!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

770 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