Solved

Hotkey independent of what has the control focus

Posted on 2004-08-04
3
281 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

730 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