Simple form with two TextBoxes, Okay, and Cancel buttons.
If condition in TextBox1 is not met, I want to keep focus on it until condition is met or Cancel button is clicked.
I have tried the following code for TextBox1:
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox1.Value = "" Then
MsgBox "Invalid entry"
TextBox1.SetFocus
TextBox1.SelStart = 0
TextBox1.SelLength = 1000
Exit Sub
End If
End Sub
Does not work. MsgBox is displayed, then focus goes to TextBox2. I have tried the above code without "Exit Sub" and had same result.
(headscratch-scratch) I'm stumped!?
If condition in TextBox1 is not met, I want to keep focus on it until condition is met or Cancel button is clicked.
I have tried the following code for TextBox1:
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox1.Value = "" Then
MsgBox "Invalid entry"
TextBox1.SetFocus
TextBox1.SelStart = 0
TextBox1.SelLength = 1000
Exit Sub
End If
End Sub
Does not work. MsgBox is displayed, then focus goes to TextBox2. I have tried the above code without "Exit Sub" and had same result.
(headscratch-scratch) I'm stumped!?