I'm having problems with setting focus on a text box from a textbox_change() event.
What I want to happen is when the text in the box gets to a certain length it triggers an event, clears the text box and sets the focus back on the now blank text box.
Here's the code:
Private Sub InputTextBox_Change()
If Len(InputTextBox.Value) = 28 Then
Sheets("Scans").Cells(FirstEmptyRow("Scans"), 1).Value = Mid(InputTextBox.Value, 18, 5)
InputTextBox.Value = ""
Update
InputTextBox.SetFocus
End If
End Sub
FirstEmptyRow and Update are both functions which I have defined elsewhere.
It might be helpful to note that this runs fine on one laptop running an older version of excel but we recently got a new computer running Windows 8 with Excel 2013 and now it doesn't work. It will do everything except setting the focus back on the text box. Instead it acts as if someone has pressed tab and selects the next element in the userform.
Thanks!
What I want to happen is when the text in the box gets to a certain length it triggers an event, clears the text box and sets the focus back on the now blank text box.
Here's the code:
Private Sub InputTextBox_Change()
If Len(InputTextBox.Value) = 28 Then
Sheets("Scans").Cells(FirstEmptyRow("Scans"), 1).Value = Mid(InputTextBox.Value, 18, 5)
InputTextBox.Value = ""
Update
InputTextBox.SetFocus
End If
End Sub
FirstEmptyRow and Update are both functions which I have defined elsewhere.
It might be helpful to note that this runs fine on one laptop running an older version of excel but we recently got a new computer running Windows 8 with Excel 2013 and now it doesn't work. It will do everything except setting the focus back on the text box. Instead it acts as if someone has pressed tab and selects the next element in the userform.
Thanks!