Moving around a userform with enter

  • Thread starter lisamariechemistry
  • Start date
L

lisamariechemistry

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?
 
C

Corey

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....
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?
 
L

lisamariechemistry

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top