ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Moving around a userform with enter (https://www.excelbanter.com/excel-programming/388887-moving-around-userform-enter.html)

[email protected]

Moving around a userform with enter
 
I have a working userform that I would like to make more user-
friendly. Four option buttons, a text box, OK and Cancel buttons.

I want the user to be able to press enter from the option button that
has the focus and go straight to the textbox without tabbing through
all the other option buttons. Ideally, pressing enter would
automatically "click" that option button but I'm ok with using
spacebar. Then, pressing enter from textbox1 still needs to activate
the OK button (as it currently does). I thought it would look
(partially) like this:

private sub optionbutton1_enter( )
textbox1.default = true
end sub

private sub textbox1_enter( )
commandbutton1.default = true 'commandbutton 1 is the OK
end sub

the error message I get when I run the form reads "Could not set the
default property, member not found." in regards to the option
button_enter, even if I comment out the textbox1_enter section. What
should I be trying?


Corey

Moving around a userform with enter
 
Try:
Option Explicit

Private Sub OptionButton1_Click()
If OptionButton1 < 0 Then TextBox1.SetFocus
End Sub

Private Sub OptionButton2_Click()
If OptionButton2 < 0 Then TextBox1.SetFocus
End Sub

Private Sub OptionButton3_Click()
If OptionButton3 < 0 Then TextBox1.SetFocus
End Sub

Private Sub OptionButton4_Click()
If OptionButton4 < 0 Then TextBox1.SetFocus
End Sub

Corey....
wrote in message
ups.com...
I have a working userform that I would like to make more user-
friendly. Four option buttons, a text box, OK and Cancel buttons.

I want the user to be able to press enter from the option button that
has the focus and go straight to the textbox without tabbing through
all the other option buttons. Ideally, pressing enter would
automatically "click" that option button but I'm ok with using
spacebar. Then, pressing enter from textbox1 still needs to activate
the OK button (as it currently does). I thought it would look
(partially) like this:

private sub optionbutton1_enter( )
textbox1.default = true
end sub

private sub textbox1_enter( )
commandbutton1.default = true 'commandbutton 1 is the OK
end sub

the error message I get when I run the form reads "Could not set the
default property, member not found." in regards to the option
button_enter, even if I comment out the textbox1_enter section. What
should I be trying?



[email protected]

Moving around a userform with enter
 
Close enough. It's only slightly different from what I had in mind
and ultimately reaches the my goal, for the user to be able to use the
form without using the mouse if they so choose. Thank you.


On May 7, 3:45 pm, "Corey" wrote:
Try:
Option Explicit

Private Sub OptionButton1_Click()
If OptionButton1 < 0 Then TextBox1.SetFocus
End Sub

Private Sub OptionButton2_Click()
If OptionButton2 < 0 Then TextBox1.SetFocus
End Sub

Private Sub OptionButton3_Click()
If OptionButton3 < 0 Then TextBox1.SetFocus
End Sub

Private Sub OptionButton4_Click()
If OptionButton4 < 0 Then TextBox1.SetFocus
End Sub

wrote in message

ups.com...
I have a working userform that I would like to make more user-
friendly. Four option buttons, a text box, OK and Cancel buttons.

I want the user to be able to press enter from the option button that
has the focus and go straight to the textbox without tabbing through
all the other option buttons. Ideally, pressing enter would
automatically "click" that option button but I'm ok with using
spacebar. Then, pressing enter from textbox1 still needs to activate
the OK button (as it currently does). I thought it would look
(partially) like this:

private sub optionbutton1_enter( )
textbox1.default = true
end sub

private sub textbox1_enter( )
commandbutton1.default = true 'commandbutton 1 is the OK
end sub

the error message I get when I run the form reads "Could not set the
default property, member not found." in regards to the option
button_enter, even if I comment out the textbox1_enter section. What
should I be trying?





All times are GMT +1. The time now is 06:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com