sharky12345
Well-known Member
- Joined
- Aug 5, 2010
- Messages
- 3,380
- Office Version
- 2016
- Platform
- Windows
I have a number of controls on a Userform, the first one of which is called 'txtdate' and when users click into that they get a calendar pop up.
The 2nd control is Textbox2 and I have placed this code so that users get an error message if they enter a number greater than 24;
The issue is that when I enter more than 24, the error message appears and the textbox clears but the cursor ends up back in txtdate, which brings the calendar up. I've tried removing the code which brings up the calendar but the cursor still goes back to txtdate.
Have I missed something obvious?
The 2nd control is Textbox2 and I have placed this code so that users get an error message if they enter a number greater than 24;
Code:
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox2.Value >= 25 Then
Call MsgBox("You cannot enter more than 24 hours", vbCritical, "Hours error")
TextBox2.Value = ""
TextBox2.SetFocus
End If
End Sub
The issue is that when I enter more than 24, the error message appears and the textbox clears but the cursor ends up back in txtdate, which brings the calendar up. I've tried removing the code which brings up the calendar but the cursor still goes back to txtdate.
Have I missed something obvious?