Hello all,
Today I am working with a text box that is the last in a frame. I've been trying to make a message box appear if the user types too many number in textbox1. I used an exit event for textbox1, but I guess that doesn't work because it is within frame1, and the next object in the tab order is textbox2 in frame2. To get around this I tried using an exit frame1 event which worked for the most part, but I wanted the focus to return to textbox1. I could backspace what was written in textbox1, but I could not write anything in textbox1. Here is my code...
What can I do to make it so I can type in textbox1 again?
Today I am working with a text box that is the last in a frame. I've been trying to make a message box appear if the user types too many number in textbox1. I used an exit event for textbox1, but I guess that doesn't work because it is within frame1, and the next object in the tab order is textbox2 in frame2. To get around this I tried using an exit frame1 event which worked for the most part, but I wanted the focus to return to textbox1. I could backspace what was written in textbox1, but I could not write anything in textbox1. Here is my code...
What can I do to make it so I can type in textbox1 again?
Code:
Private Sub Frame1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim itemcode As String
Dim w
itemcode = Me.tbItemCode
itemcode = Replace(itemcode, " ", "")
w = CountNumbers(itemcode)
If w > 5 Then
Cancel = True
MsgBox ("Item code number has too many numbers. Please double check.")
Me.Frame1.SetFocus
With Me.tbItemCode
.SelStart = 0
.SelLength = Len(Me.tbItemCode.Text)
.SetFocus
End With
End If
End Sub