Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Assign hotkey to textbox for setfocus

Posted on 2001-07-16
6
Medium Priority
?
269 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
[X]
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
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

704 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