Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting OptionButtons
Hi
Say for example there are 2 form optbuttons in a frame; is it possible to tab to the required option and 'click' the button using the Enter key? If so how? My form has a number of optionbuttons amongst textboxes and it is becoming tedious to keep reaching for the mouse to make a choice or confirm something. It would be great to just use the keyboard as far as possible. T.I.A Geoff |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting OptionButtons
Spacebar, Geoff. :)
******************* ~Anne Troy www.OfficeArticles.com "Geoff" wrote in message ... Hi Say for example there are 2 form optbuttons in a frame; is it possible to tab to the required option and 'click' the button using the Enter key? If so how? My form has a number of optionbuttons amongst textboxes and it is becoming tedious to keep reaching for the mouse to make a choice or confirm something. It would be great to just use the keyboard as far as possible. T.I.A Geoff |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting OptionButtons
Probably not an issue but ensure that the option buttons properties are
correct. Tab Stop it True and Tab index is in the correct order... -- HTH... Jim Thomlinson "Anne Troy" wrote: Spacebar, Geoff. :) ******************* ~Anne Troy www.OfficeArticles.com "Geoff" wrote in message ... Hi Say for example there are 2 form optbuttons in a frame; is it possible to tab to the required option and 'click' the button using the Enter key? If so how? My form has a number of optionbuttons amongst textboxes and it is becoming tedious to keep reaching for the mouse to make a choice or confirm something. It would be great to just use the keyboard as far as possible. T.I.A Geoff |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting OptionButtons
Spacebar works fine when focus is on a frame which has an Exit event with
Cancel = True clause. Thank you:):) But in another part of the form I have 4 pairs of txtboxes, each pair representing hours and minutes. After a correct entry, I move the focus by SetFocus from one txtbox to the next. The first 3 pairs are summed after entering minutes in the 3rd pair(box 6) and the total is shown in pair 4. To assist data entry in the 3rd pair I have an optionbutton which reveals a 'totaliser' for that pair only. Using the mouse I can click for this function before data is entered into the 3rd pair or just enter directly. Here is the problem with the Spacebar solution. Despite using tabstop=true and tab order etc I cannot navigate to this option button to use the Spacebar, I assume because of the coded tabbing to the 4th pair of boxes. Does this make sense? I wondered if i should be using Application.OnKey somehow? Geoff "Anne Troy" wrote: Spacebar, Geoff. :) ******************* ~Anne Troy www.OfficeArticles.com "Geoff" wrote in message ... Hi Say for example there are 2 form optbuttons in a frame; is it possible to tab to the required option and 'click' the button using the Enter key? If so how? My form has a number of optionbuttons amongst textboxes and it is becoming tedious to keep reaching for the mouse to make a choice or confirm something. It would be great to just use the keyboard as far as possible. T.I.A Geoff |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting OptionButtons
Geoff,
Do you have an accelerator key set on the option button? Enter a character from the button caption in the "Accelerator" property in the VBE. Then use Alt + (that character) to activate the button. Regards, Jim Cone San Francisco, USA "Geoff" wrote in message ... Spacebar works fine when focus is on a frame which has an Exit event with Cancel = True clause. Thank you:):) But in another part of the form I have 4 pairs of txtboxes, each pair representing hours and minutes. After a correct entry, I move the focus by SetFocus from one txtbox to the next. The first 3 pairs are summed after entering minutes in the 3rd pair(box 6) and the total is shown in pair 4. To assist data entry in the 3rd pair I have an optionbutton which reveals a 'totaliser' for that pair only. Using the mouse I can click for this function before data is entered into the 3rd pair or just enter directly. Here is the problem with the Spacebar solution. Despite using tabstop=true and tab order etc I cannot navigate to this option button to use the Spacebar, I assume because of the coded tabbing to the 4th pair of boxes. Does this make sense? I wondered if i should be using Application.OnKey somehow? Geoff "Anne Troy" wrote: Spacebar, Geoff. :) ******************* ~Anne Troy www.OfficeArticles.com "Geoff" wrote in message ... Hi Say for example there are 2 form optbuttons in a frame; is it possible to tab to the required option and 'click' the button using the Enter key? If so how? My form has a number of optionbuttons amongst textboxes and it is becoming tedious to keep reaching for the mouse to make a choice or confirm something. It would be great to just use the keyboard as far as possible. T.I.A Geoff |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting OptionButtons
Jim
Thanks for the reply. That works fine in this layout. I have a number of frames to test but up to now it has performed as needed. Because of the number of buttons and similarity of captions i guess i will have to be inventive with the key letter. Accelerator plus spacebar plus tab order should give me plenty options (sorry - couldn't resist that) to play with. Thanks to all for their contribution. Geoff "Jim Cone" wrote: Geoff, Do you have an accelerator key set on the option button? Enter a character from the button caption in the "Accelerator" property in the VBE. Then use Alt + (that character) to activate the button. Regards, Jim Cone San Francisco, USA "Geoff" wrote in message ... Spacebar works fine when focus is on a frame which has an Exit event with Cancel = True clause. Thank you:):) But in another part of the form I have 4 pairs of txtboxes, each pair representing hours and minutes. After a correct entry, I move the focus by SetFocus from one txtbox to the next. The first 3 pairs are summed after entering minutes in the 3rd pair(box 6) and the total is shown in pair 4. To assist data entry in the 3rd pair I have an optionbutton which reveals a 'totaliser' for that pair only. Using the mouse I can click for this function before data is entered into the 3rd pair or just enter directly. Here is the problem with the Spacebar solution. Despite using tabstop=true and tab order etc I cannot navigate to this option button to use the Spacebar, I assume because of the coded tabbing to the 4th pair of boxes. Does this make sense? I wondered if i should be using Application.OnKey somehow? Geoff "Anne Troy" wrote: Spacebar, Geoff. :) ******************* ~Anne Troy www.OfficeArticles.com "Geoff" wrote in message ... Hi Say for example there are 2 form optbuttons in a frame; is it possible to tab to the required option and 'click' the button using the Enter key? If so how? My form has a number of optionbuttons amongst textboxes and it is becoming tedious to keep reaching for the mouse to make a choice or confirm something. It would be great to just use the keyboard as far as possible. T.I.A Geoff |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting OptionButtons
On further testing of Accelerator I have a problem.
I use a label to name an optbutton rather than its caption. When I set an accelerator on the optbutton the function works fine. If I set an accelerator on the label it does not, yet according to VB Help: 'If the accelerator applies to a Label, the control following the Label in the tab order, rather than the Label itself, receives the focus.' Any further suggestions other than use the optbutton caption? Geoff "Geoff" wrote: Jim Thanks for the reply. That works fine in this layout. I have a number of frames to test but up to now it has performed as needed. Because of the number of buttons and similarity of captions i guess i will have to be inventive with the key letter. Accelerator plus spacebar plus tab order should give me plenty options (sorry - couldn't resist that) to play with. Thanks to all for their contribution. Geoff "Jim Cone" wrote: Geoff, Do you have an accelerator key set on the option button? Enter a character from the button caption in the "Accelerator" property in the VBE. Then use Alt + (that character) to activate the button. Regards, Jim Cone San Francisco, USA "Geoff" wrote in message ... Spacebar works fine when focus is on a frame which has an Exit event with Cancel = True clause. Thank you:):) But in another part of the form I have 4 pairs of txtboxes, each pair representing hours and minutes. After a correct entry, I move the focus by SetFocus from one txtbox to the next. The first 3 pairs are summed after entering minutes in the 3rd pair(box 6) and the total is shown in pair 4. To assist data entry in the 3rd pair I have an optionbutton which reveals a 'totaliser' for that pair only. Using the mouse I can click for this function before data is entered into the 3rd pair or just enter directly. Here is the problem with the Spacebar solution. Despite using tabstop=true and tab order etc I cannot navigate to this option button to use the Spacebar, I assume because of the coded tabbing to the 4th pair of boxes. Does this make sense? I wondered if i should be using Application.OnKey somehow? Geoff "Anne Troy" wrote: Spacebar, Geoff. :) ******************* ~Anne Troy www.OfficeArticles.com "Geoff" wrote in message ... Hi Say for example there are 2 form optbuttons in a frame; is it possible to tab to the required option and 'click' the button using the Enter key? If so how? My form has a number of optionbuttons amongst textboxes and it is becoming tedious to keep reaching for the mouse to make a choice or confirm something. It would be great to just use the keyboard as far as possible. T.I.A Geoff |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting OptionButtons
Geoff,
As Anne said: "spacebar" Jim Cone "Geoff" wrote in message ... On further testing of Accelerator I have a problem. I use a label to name an optbutton rather than its caption. When I set an accelerator on the optbutton the function works fine. If I set an accelerator on the label it does not, yet according to VB Help: 'If the accelerator applies to a Label, the control following the Label in the tab order, rather than the Label itself, receives the focus.' Any further suggestions other than use the optbutton caption? Geoff "Geoff" wrote: Jim Thanks for the reply. That works fine in this layout. I have a number of frames to test but up to now it has performed as needed. Because of the number of buttons and similarity of captions i guess i will have to be inventive with the key letter. Accelerator plus spacebar plus tab order should give me plenty options (sorry - couldn't resist that) to play with. Thanks to all for their contribution. Geoff |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting OptionButtons
Hi,
what about something like this: Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Private Sub OptionButton1_Enter() If GetAsyncKeyState(vbKeyMenu) And &H8000 Then OptionButton1.Value = True End Sub Private Sub OptionButton1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = Asc(UCase(Label1.Accelerator)) And Shift = 4 Then OptionButton1.Value = True End Sub Private Sub OptionButton2_Enter() If GetAsyncKeyState(vbKeyMenu) And &H8000 Then OptionButton2.Value = True End Sub Private Sub OptionButton2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = Asc(UCase(Label2.Accelerator)) And Shift = 4 Then OptionButton2.Value = True End Sub -- HTH okaizawa Geoff wrote: On further testing of Accelerator I have a problem. I use a label to name an optbutton rather than its caption. When I set an accelerator on the optbutton the function works fine. If I set an accelerator on the label it does not, yet according to VB Help: 'If the accelerator applies to a Label, the control following the Label in the tab order, rather than the Label itself, receives the focus.' Any further suggestions other than use the optbutton caption? Geoff |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting OptionButtons
Hi okaizawa
Thats cool! Prime objective reached. 1. I can maintain the labels, which in a number of cases have to be above the optbutton (hence no button captions). 2. It saves a key depression in operation, which with a detailed data entry form saves time and patience - every little bit helps. Again thanks to all for their help. Two solutions for one problem can't be bad. Geoff "okaizawa" wrote: Hi, what about something like this: Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Private Sub OptionButton1_Enter() If GetAsyncKeyState(vbKeyMenu) And &H8000 Then OptionButton1.Value = True End Sub Private Sub OptionButton1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = Asc(UCase(Label1.Accelerator)) And Shift = 4 Then OptionButton1.Value = True End Sub Private Sub OptionButton2_Enter() If GetAsyncKeyState(vbKeyMenu) And &H8000 Then OptionButton2.Value = True End Sub Private Sub OptionButton2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = Asc(UCase(Label2.Accelerator)) And Shift = 4 Then OptionButton2.Value = True End Sub -- HTH okaizawa Geoff wrote: On further testing of Accelerator I have a problem. I use a label to name an optbutton rather than its caption. When I set an accelerator on the optbutton the function works fine. If I set an accelerator on the label it does not, yet according to VB Help: 'If the accelerator applies to a Label, the control following the Label in the tab order, rather than the Label itself, receives the focus.' Any further suggestions other than use the optbutton caption? Geoff |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
UserForm OptionButtons | Excel Discussion (Misc queries) | |||
Moving OptionButtons | Excel Discussion (Misc queries) | |||
OptionButtons | Excel Programming | |||
Add OptionButtons in Excel | Excel Programming | |||
optionbuttons | Excel Programming |