Hi all,
I need to provide shortcut keys for controls like text box and buttons etc...
That is i dont want to go for tabspace or mouse click for perticular controls..
By having shortcut keys i need to go for specifeid controls(textbox,button)...
Is there any way to provide shotcut keys for controls.....or built in property values.....
could any anoe help me out of this query...
16 25554
Hi,
For Buttons You can Change the Caption:
&Save
So, cmdsave_Click will be fired, when you press "Alt + S" on the form..
For TextBoxes, you have to code..
REgards
Veena
If you want the textbox or any control to be on focus, with an appropriate shortcut key and keypress event
Hello
Firstly Set Forms Property Keypreview True
Then Set All Controls in the Form have regular TAbIndex
Then in Form keydown event -
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
-
sendkeys vbtab
-
End Sub
-
Hi all,
I need to provide shortcut keys for controls like text box and buttons etc...
That is i dont want to go for tabspace or mouse click for perticular controls..
By having shortcut keys i need to go for specifeid controls(textbox,button)...
Is there any way to provide shotcut keys for controls.....or built in property values.....
could any anoe help me out of this query...
Hi all,
Sorry to "butt in" on this, but I have the same issue, and the answers so far does not seem to do the trick, or maybe I am doing it wrong....
If I have a form with a button called Open Details which opens another form. If I wish to use a shortcut key (instead of clicking the button with the mouse), e.g. Alt+O, how do I do that ? Is there functionality, or code to be used ?
Thanks
Best regards
Ingrid
Hi all,
Sorry to "butt in" on this, but I have the same issue, and the answers so far does not seem to do the trick, or maybe I am doing it wrong....
If I have a form with a button called Open Details which opens another form. If I wish to use a shortcut key (instead of clicking the button with the mouse), e.g. Alt+O, how do I do that ? Is there functionality, or code to be used ?
Thanks
Best regards
Ingrid
Depending on the version you can use Veena's solution, but lotus' one is more general, add in the form's keypress event the code to call the click event's sub of the button, for example, something like this in te form keydown button will do: - If KeyCode = Asc("O") And Shift = 2 Then CommandButton1_Click
add it to the controls that can be selected, so when they're selected and you press Ctrl+O the command1_click sub will be called. It'll be some copypaste work if you have many commands, but is the simplest way for few.
Note 2 is the value of Ctrl. check the help file or the object browser to see the shift or alt values, you can also use vb constants.
HTH
Both people who have the problem, please tell us what version of VB you're using.
If using VB 6.0 then it is quite easy to set focus for text boxes.
1.Use a label control for the labeling of the textbox .
2.UseMnemonic should be set to true for the label (default).
3.Use & to assign the Mnemonic.
4.Set the tab index of the textbox to one more than the corresponding label.
When you try set the focus on the label using the Mnemonic character and since label is a static control so could not receive the focus , focus will be set to next control in higher tab index order.
Thanks Debasis. Exactly what I would have said, if I'd had time. :)
Hi,
Just provide the &Open Details at the text property of the button.
while running the form if u fired Alt+O ,it automatically fires the function of button(open details)-- which opens another form.
Regards
suji
Hi all,
thanks a lot for the many replies, and sorry for not being in here for so long, however now I am back and can reply to some of the suggestions and questions.
I am using VB 6,5 with Access 2007.
Thanks HTH for your suggestion code, I just tried it out, but it doesnt seem to work, or I am doing it wrong. I used the code you provided and set it into the OnKeyDown property of the Form as
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = Asc("O") And Shift = 2 Then Command142_Click
End Sub
Command142 being the button I want to open. But when I press Ctrl+O nothing happens..... what am I doing wrong ?
Suji, I am not quite sure I understand your suggestion, could you please elaborate ?
I hope you can still help me....
Thanks in advance
Best regards
Ingrid
Thanks HTH for your suggestion code, I just tried it out, but it doesnt seem to work, or I am doing it wrong. I used the code you provided and set it into the OnKeyDown property of the Form as
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = Asc("O") And Shift = 2 Then Command142_Click
End Sub
Command142 being the button I want to open. But when I press Ctrl+O nothing happens..... what am I doing wrong ?
HTH = hope that helps
Call me Kad
Its because as your form has many controls, when you initilialize the form, what is selected is not the form, but another control. So for Ctrl-O to work it has to be in the KeyDown event of the selected control. (so you can write it on every control key down event)
HTH (again ^.^)
Hi Kad,
Sorry about the HTH :-)
Anyway I tried it and it works when I am already placed on the command, however is there a way of using shortcut keys to activate a command, or go to a specific field without being placed on the command already ?
My reason for wanting this function is that I will use it as shortcuts for a user, being anywhere in the form, and instead of using the mouse, or the tabs to "get there" I would want to use a shortcutkey.... sorry if I explained my issue wrong earlier....
Thanks in advance
Best regards
Ingrid
Close of this issue since solution has been provided
I think this is the final solution and will be beneficial for everyone:
Use the code below: -
Dim A As Integer
-
Dim B As Integer
-
-
Sub SetControlFocus(KeyCode As Integer, Shift As Integer)
-
If KeyCode = Asc("A") And Shift = 2 Then Command1_Click
-
If KeyCode = Asc("B") And Shift = 2 Then Command2_Click
-
If KeyCode = Asc("D") And Shift = 2 Then Text1.SetFocus
-
If KeyCode = Asc("E") And Shift = 2 Then Text2.SetFocus
-
If KeyCode = Asc("F") And Shift = 2 Then Text3.SetFocus
-
If KeyCode = Asc("G") And Shift = 2 Then Option1.SetFocus
-
-
'MsgBox "OK"
-
End Sub
-
-
Private Sub Command1_Click()
-
MsgBox "Clicked Command Button 1"
-
End Sub
-
-
Private Sub Command2_Click()
-
MsgBox "Clicked Command Button 2"
-
End Sub
-
-
Private Sub Option1_KeyDown(KeyCode As Integer, Shift As Integer)
-
A = KeyCode: B = Shift
-
If B <> 0 Then
-
If B = 2 And A <> 17 Then
-
Call SetControlFocus(A, B)
-
End If
-
End If
-
End Sub
-
Write the code in Option1_KeyDown event in every control's key down event and the results will be as required. If satisfied please post reply.
very helpful and successfully work
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Nick |
last post by:
In VS 2003 and VS 2005 beta 2 I am trying to write a simple program. It has
a datagrid and a textbox along with a menubar. There is a command in the
menu bar which is "Run Query" and has the...
|
by: Saper\(ek\) |
last post by:
this is a strange behavior of buttons with shortcut keys, when You have a
datagrid on a form and some buttons with shortcut keys. When You click on
the datagrid (anywhere but the cells, free space,...
|
by: Aaron |
last post by:
How can I add a shortcut key to a button in a windows app.?
for example
i have a button called submit and right now the only way to execute
its function is to left click the button. I would like...
|
by: BuddyWork |
last post by:
Hello,
If you copy the source code from this post into seperate
files as stated, and compile the code.
Now to reproduce run the code in debug.
1. Press the Client button.
2. Put the cursor...
|
by: Shailja |
last post by:
Hi,
How to provide shortcut keys to toolbar button? If i write &New in caption property of button, which key should i use with N?
Kindly let me know.
|
by: thirunavukarasukm |
last post by:
Hai...
How to Usercontrols with Shortcut Keys...
I am creating one windows apllication..
the apllication contain many form..
in one form i am used one usercontrol(parent control)..
|
by: karthickbabu |
last post by:
Hi
How can i create shortcut keys for Button Controls in vb.net. I am using MDI form and Child Form. I want to create shortcut key for button in ChildForm. Actually i created but when i press...
|
by: sujathaeeshan |
last post by:
Hi all,
I need to provide shortcut keys for controls like text box and buttons etc...
That is i dont want to go for tabspace or mouse click for perticular controls..
By having shortcut keys i...
|
by: Andrus |
last post by:
If focused control is ReadOnly, menu shortcut key is ignored.
To reproduce, run code below, press Ctrl+E.
Note that message box does not appear.
This issue blocks Ctrl+E usage in application....
|
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= |
last post by:
Hello,
I have a textbox containing a listview of items. I would like to set it up
so that when that textbox has the focus and I press ctl-A from the keyboard
it selects all the items. Dealing...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| | |