Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Assign hotkey to textbox for setfocus

Posted on 2001-07-16
6
Medium Priority
?
277 Views
Last Modified: 2006-11-17
I design a form and there are different labels and textbox. I want to go on specific textbox by pressing Alt+F key from keyboard. How it is possible ?

Saleem
0
Comment
Question by:pak_slm
6 Comments
 
LVL 11

Expert Comment

by:Otana
ID: 6285329
a simple way is to create a command button out of sight, with a shortcut Alt+F, and then in the onclick event set:

text1.setfocus
0
 
LVL 4

Accepted Solution

by:
VincentLawlor earned 75 total points
ID: 6285350
On your main form set KeyPreview = True

In your KeyDown code on the main form

Place the following

Dim AltDown
AltDown = (Shift And vbAltMask) > 0

If KeyCode = vbKeyF Then
  If AltDown Then TextBox1.SetFocus
End If
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6285374
If you have a label describing the textbox, you can set the hotkey in the label's caption using the & character as normal. In order for this to work, you must ensure that the tab order (specified by the tabindex property for each control) places the label one place lower than the corresponding textbox:

Label1    TabIndex = 0
Text1     TabIndex = 1

Label1.Caption = "&Hello There"

In this scenario pressing Alt+H would set focus to the text box as the subsequent control in the tab order.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:pak_slm
ID: 6285431
I prefer your answer because it is code based.
Thanks.
0
 
LVL 4

Expert Comment

by:VincentLawlor
ID: 6285446
Your welcome
0
 
LVL 1

Author Comment

by:pak_slm
ID: 6285466
If i place a button or through label caption then i feel problem because i want more then one hotkey.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

876 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