MR Campbell
Board Regular
- Joined
- Aug 2, 2002
- Messages
- 113
I have a Textbox on a Sheet and after the user types a 4 digit code into the Textbox, I want to trigger a procedure.
After that procedure is finished, I want to erase what was in the textbox and then have the user type more 4 digit codes. I want to put the cursor back in the Textbox after the previous code is erased. So far I have tried this ....
Private Sub TextBox_Change()
Dim CodeText As String 'code entered in
CodeText = Sheets("Sheet1").TextBox.Text
'Test whether 4 characters are captured
If Len(CodeText) = 4 Then
Call ProcessLastCode(CodeText)
'Clear the textbox and set the focus
Sheets("Sheet1").TextBox.Value = ""
Sheets("Sheet1").TextBox.SetFocus
End If
End Sub
The error message generated says that the object TextBox cannot accept the SetFocus method/property.
Please help.
After that procedure is finished, I want to erase what was in the textbox and then have the user type more 4 digit codes. I want to put the cursor back in the Textbox after the previous code is erased. So far I have tried this ....
Private Sub TextBox_Change()
Dim CodeText As String 'code entered in
CodeText = Sheets("Sheet1").TextBox.Text
'Test whether 4 characters are captured
If Len(CodeText) = 4 Then
Call ProcessLastCode(CodeText)
'Clear the textbox and set the focus
Sheets("Sheet1").TextBox.Value = ""
Sheets("Sheet1").TextBox.SetFocus
End If
End Sub
The error message generated says that the object TextBox cannot accept the SetFocus method/property.
Please help.