BPatters
01-16-2014, 03:04 PM
OK, So I got saddled with working on a form at work. In the form, I'm trying to add a message box that pops up if you don't enter the correct number of digits in the associated textbox for a phone number. At this point, the message box pops up fine, however, the cursor moves to the next message box despite the error. I have played with the retry/cancel button feature and have not been succesful to this point. Currently all there is is a box that pops up to tell you that the information you've entered is invalid.
What I'm trying to accomplish is, have a message box pop up with the Retry and Cancel options. That much I've figured out. But, if you push cancel, it should allow the cursor to move on to the next textbox. If you push retry, the textbox should clear and remian in the current textbox. I've stripped all but the basic code out.
I also should mention that all of my vba coding has come from goole and trial and error. I know nothing about the correct syntax when it comes to writing code. Any help/suggestions you can provide would be greatly appreciated. Here is the current code for the offending textbox.
Thanks
Private Sub TextBox6_LostFocus()
Me.TextBox6.Value = Format(TextBox6.Text, "(###) ###-####")
If Len(TextBox6.Text) <> 14 Then
TextBox6.Text = ""
If Len(TextBox6.Text) <> 14 Then
MsgBox "Please Enter a 10 Digit Phone Number"
End If
End If
End Sub
What I'm trying to accomplish is, have a message box pop up with the Retry and Cancel options. That much I've figured out. But, if you push cancel, it should allow the cursor to move on to the next textbox. If you push retry, the textbox should clear and remian in the current textbox. I've stripped all but the basic code out.
I also should mention that all of my vba coding has come from goole and trial and error. I know nothing about the correct syntax when it comes to writing code. Any help/suggestions you can provide would be greatly appreciated. Here is the current code for the offending textbox.
Thanks
Private Sub TextBox6_LostFocus()
Me.TextBox6.Value = Format(TextBox6.Text, "(###) ###-####")
If Len(TextBox6.Text) <> 14 Then
TextBox6.Text = ""
If Len(TextBox6.Text) <> 14 Then
MsgBox "Please Enter a 10 Digit Phone Number"
End If
End If
End Sub