By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,916 Members | 1,068 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,916 IT Pros & Developers. It's quick & easy.

What is the Validation Rule for a certain number of digits phone number?

100+
P: 176
I haven't found anything that would help me to understand the correct syntax for having a certain number of digits phone number validation rule.

My input mask for this field is: \000\-0000000;;
When I set the following validation rule: 9999999999 or =9999999999 it doesn't work correctly and it allows short numbers.

How should I compose it correctly.

Thanks, Michael.
Feb 7 '07 #1
Share this Question
Share on Google+
6 Replies


ADezii
Expert 5K+
P: 8,638
I haven't found anything that would help me to understand the correct syntax for having a certain number of digits phone number validation rule.

My input mask for this field is: \000\-0000000;;
When I set the following validation rule: 9999999999 or =9999999999 it doesn't work correctly and it allows short numbers.

How should I compose it correctly.

Thanks, Michael.
0 - Digit (0 to 9, entry required, plus [+] and minus [] signs not allowed).
9 - Digit or space (entry not required, plus and minus signs not allowed).
Feb 7 '07 #2

100+
P: 1,646
Your input mask will give you a 3 digit area code always starting with 0 followed by 6 digits. The only thing your validation rule can check for is if the field has been filled in by the user or left blank and only if the field has changed. The mask will take care of validating input
Feb 7 '07 #3

100+
P: 176
Your input mask will give you a 3 digit area code always starting with 0 followed by 6 digits. The only thing your validation rule can check for is if the field has been filled in by the user or left blank and only if the field has changed. The mask will take care of validating input
You are right,
Thanks.

Is there a way to customize the error message the intput masks returns?
Feb 7 '07 #4

MSeda
Expert 100+
P: 159
On a form you can you run validations in a controls before update event like
Expand|Select|Wrap|Line Numbers
  1.  if Len(me.textbox) <> 10 then
  2. msgbox "Phone # must have ten digits"
  3. cancel=true
  4. end if  
unfortunately on the table level you get what you get for validations and error messages.
Feb 8 '07 #5

P: 29
Thank you very much for solving a problem that comes up when beginners like me begin to program. I appreciate your knowledge.

Thank you again for chosing to share. Your answer worked when placed in a form.

Shiznaw 11-24-09
Nov 24 '09 #6

missinglinq
Expert 2.5K+
P: 3,532
@Michael R
This will do that, 2279 being the error code for data not matching the Input Mask:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Error(DataErr As Integer, Response As Integer)
  2. Dim Message As String
  3.  If DataErr = 2279 Then 'Data entered doesn't match Input Mask
  4.   Message = "You Have Entered Invalid Data For The Field: " & Me.ActiveControl.Name
  5.   Response = MsgBox(Message, vbExclamation, "Invalid Value Entered")
  6.   Response = acDataErrContinue
  7.  End If
  8. End Sub
Linq ;0)>
Nov 24 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.