Hello, new to the board. I'm using a control text box on a template, I named the box Originator. I want to require the user to fill in their name - can someone help me please! Something short and sweet.
I haven't received any feedback, but I added this code:
Private Sub Originator_Change()
If Originator.Text = "" Then
MsgBox "You Must Enter Your Last Name First Name"
But it only works if I add some text into the box and then backspace and delete everything. I need something that will check to see if the text box is empty after the user clicks out of the box. Also, add a check if the user tries to save the file without filling in the text box. Please help!
So far I've tried the following that I have found on different boards and placed the code in my Sheet1 code window. I'm obviously hacking since I've never done this before...
Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If Len(TextBox1.Text) = 0 Then
MsgBox "Required field."
TextBox1.Text = Left(TextBox1.Text, 5)
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox1.Value = "" Then
MsgBox "Required Field."
I'm trying to make the user put something in the empty field when they try to tab over or access the next field. Or it would be great if I could do a check for all required fields when the form is completed.