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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Michael R
    New Member
    • Nov 2006
    • 176

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

    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.
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by Michael R
    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).

    Comment

    • willakawill
      Top Contributor
      • Oct 2006
      • 1646

      #3
      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

      Comment

      • Michael R
        New Member
        • Nov 2006
        • 176

        #4
        Originally posted by willakawill
        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?

        Comment

        • MSeda
          Recognized Expert New Member
          • Sep 2006
          • 159

          #5
          On a form you can you run validations in a controls before update event like
          Code:
           if Len(me.textbox) <> 10 then
          msgbox "Phone # must have ten digits"
          cancel=true
          end if
          unfortunately on the table level you get what you get for validations and error messages.

          Comment

          • shiznaw
            New Member
            • Jun 2007
            • 29

            #6
            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

            Comment

            • missinglinq
              Recognized Expert Specialist
              • Nov 2006
              • 3533

              #7
              Originally posted by Michael R
              Is there a way to customize the error message the input masks returns?
              This will do that, 2279 being the error code for data not matching the Input Mask:
              Code:
              Private Sub Form_Error(DataErr As Integer, Response As Integer)
              Dim Message As String
               If DataErr = 2279 Then 'Data entered doesn't match Input Mask
                Message = "You Have Entered Invalid Data For The Field: " & Me.ActiveControl.Name
                Response = MsgBox(Message, vbExclamation, "Invalid Value Entered")
                Response = acDataErrContinue
               End If
              End Sub
              Linq ;0)>

              Comment

              Working...