Hello and thank you for any attention my post may receive.
I have a Userform with 24 textboxes and multiple comboboxes. The problem I have is when using the key down/up to read the wrapped text in a textbox the cursor leaves the textbox and enters combobox. if I don't realise this and continue to press the arrow key the combobox value changes.
I have this code in the Userform but it does not keep the arrow key in the textbox. I also thought of trying to restrict moving about the userform to only tab or mouse function but am not sure if that is the best solution.
Any help or suggestions would be greatly appreciated.
Thank you and have a great day!
I have a Userform with 24 textboxes and multiple comboboxes. The problem I have is when using the key down/up to read the wrapped text in a textbox the cursor leaves the textbox and enters combobox. if I don't realise this and continue to press the arrow key the combobox value changes.
I have this code in the Userform but it does not keep the arrow key in the textbox. I also thought of trying to restrict moving about the userform to only tab or mouse function but am not sure if that is the best solution.
Any help or suggestions would be greatly appreciated.
Code:
Private Sub Userform_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyDown Then
With Me.TextBox
If .LineCount > 1 And _
.CurLine = .LineCount - 1 Then
Beep
.SetFocus
.CurLine = .LineCount - 2
.SetFocus
End If
End With
End If
If KeyCode = vbKeyUp Then
With Me.TextBox
If .LineCount > 1 And _
.CurLine = 0 Then
Beep
.SetFocus
.CurLine = 1
End If
End With
End If
End Sub
Thank you and have a great day!