Assign hotkey to textbox for setfocus

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
LVL 1
pak_slmAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
VincentLawlorConnect With a Mentor Commented:
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
 
OtanaCommented:
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
 
TimCotteeCommented:
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
pak_slmAuthor Commented:
I prefer your answer because it is code based.
Thanks.
0
 
VincentLawlorCommented:
Your welcome
0
 
pak_slmAuthor Commented:
If i place a button or through label caption then i feel problem because i want more then one hotkey.
0
All Courses

From novice to tech pro — start learning today.