Pookiemeister
Well-known Member
- Joined
- Jan 6, 2012
- Messages
- 626
- Office Version
- 365
- 2010
- Platform
- Windows
Inside a userform, I have a frame and a textbox. Inside the frame I have six option buttons. When the form initializes none of the option buttons are selected but as soon as the user selects any of the option buttons I need it to tab to the next control (textbox1). Is there not an easier way to do this? When I web searched this, one website stated that a class had to be created and then a whole bunch of code, which made no sense to me. Here is what I have so far. This code will work when assigned to a command button but I would like to avoid using a command button. I have tried using two different events for this to see how the results would be different and here they are:
The first way gave me a run time error 13: Type Mismatch.
The second way doesn't do anything.
The use of the msgbox in both examples is for test purposes only. Thank you all for any help given.
The first way gave me a run time error 13: Type Mismatch.
Code:
Private Sub Frame1_Enter()
Dim optBtn As OptionButton
For Each optBtn In Me.Frame1.Controls
If optBtn.Value = True Then
MsgBox optBtn.Caption
End If
Next
End Sub
Code:
Private Sub Frame1_Click()
Dim optBtn As OptionButton
For Each optBtn In Me.Frame1.Controls
If optBtn.Value = True Then
MsgBox optBtn.Caption
End If
Next
End Sub
Last edited: