RE: Required Field for 7 Numeric digits only
- From: JLGWhiz <JLGWhiz@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 30 Mar 2008 11:58:00 -0700
Right click your TextBox1>View Code then paste the snippet below in behind
the TextBox control. It should then reactivate the text box if someone
closes it with less than seven digits entered.
Private Sub TextBox1_LostFocus()
If Len(TextBox1.Text) <> 7 Then
TextBox1.Activate
End If
End Sub
"LRay67" wrote:
I didn't have my current code when I posed this question. Below is the code.
we are using for this particular textbox. I would like the user to be able
to enter data into the field and upon tabbing or leaving the field verify
that they have 7 numeric digits entered (nothing more or less than that). We
have a message stating that they have to enter if nothing is filled
in.......Any suggestions
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = vbKeyTab Then
If TextBox1 = "" Then
MsgBox "Please enter Accounting Unit Code (7 Digits)"
Application.SendKeys ("{BS}")
TextBox1.Activate
Exit Sub
End If
KeyAscii = 0
TextBox3.Activate
End If
End Sub
"JLGWhiz" wrote:
This should cover it all, needed to make the loop so they have to respond.
RETRY:
UserInput = Application.InputBox("Enter an seven numeric digits", _
"NUMERIC ONLY", Type:=1)
If UserInput = "" Or UserInput = False Or Len(UserInput) <> 7 Then
MsgBox "You must enter numbers only."
GoTo RETRY:
End If
"LRay67" wrote:
I have a required field that can contain only 7 numeric digits within the
textbox. Also want to put in a message box to alert them that this field
must have 7 numeric digits. Any suggestions on how to write the code behind
this? Thanks
Linda
- Follow-Ups:
- RE: Required Field for 7 Numeric digits only
- From: LRay67
- RE: Required Field for 7 Numeric digits only
- From: JLGWhiz
- Re: Required Field for 7 Numeric digits only
- From: Rick Rothstein \(MVP - VB\)
- RE: Required Field for 7 Numeric digits only
- References:
- Required Field for 7 Numeric digits only
- From: LRay67
- RE: Required Field for 7 Numeric digits only
- From: JLGWhiz
- RE: Required Field for 7 Numeric digits only
- From: LRay67
- Required Field for 7 Numeric digits only
- Prev by Date: Re: Required Field for 7 Numeric digits only
- Next by Date: Re: Required Field for 7 Numeric digits only
- Previous by thread: Re: Required Field for 7 Numeric digits only
- Next by thread: Re: Required Field for 7 Numeric digits only
- Index(es):
Relevant Pages
|
Loading