How do I Form the Input Mask Correctly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mmwit
    New Member
    • Jan 2013
    • 15

    How do I Form the Input Mask Correctly

    hello all!
    I have a table in access 2010 that it contains a column with a short code, and it required only 6 digits not less than and not more than 6 it must be fix 6 numbers (e.g 123456) this is correct, but (e.g 1234567) NOT correct,

    I don't know how to mask this please help Me as soon as possible
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    open the table design
    select the field
    select the validation field
    press [f1]

    also
    Allen Brown - Validation Rules

    I would also consider doing this kind of check at the form level.
    Last edited by zmbd; Jan 27 '13, 07:33 AM. Reason: [z{mis-key}]

    Comment

    • Narender Sagar
      New Member
      • Jul 2011
      • 189

      #3
      You can do this using "Input Mask" control.
      Select your field and enter 6 times "0"
      (with 0 means : y0u can enter Digit (0 to 9, entry required, plus [+] and minus [–] signs not allowed).
      As mentioned by Z: You can see more option pressing F1.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32637

        #4
        The Input Mask property you would use for that would simply be "000000". Quotes (") not required.

        Comment

        • mmwit
          New Member
          • Jan 2013
          • 15

          #5
          I have tried it all the options, but positive result, still when I'm insterting number in that field it accepts, more and less than 6 numbers

          i want this field only accepts 6 digits of number (NO more/less)

          Comment

          • Seth Schrock
            Recognized Expert Specialist
            • Dec 2010
            • 2965

            #6
            Did you try the validation rule Is Null OR Between 100000 And 999999? If the control must have a value in it, you can skip the Is Null portion to leave just Between 100000 And 999999.

            This was found in Z's link and I would be very much surprised if it didn't work. Be sure to read the link and also read the section When to use validation rules, Field's validation rule. It provides some good insight about considerations you need to make before using validation rules.

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32637

              #7
              Originally posted by Access InputMask Help
              Access InputMask Help:
              0 - Digit (0 to 9, entry required, plus [+] and minus [-] signs not allowed).
              I'm surprised you say it doesn't work for you. I can only assume you have not entered it correctly. I thought the instructions were very explicit. Don't enter any quote characters into the InputMask property, but just six zeroes. You should find that works for you.

              Comment

              • zmbd
                Recognized Expert Moderator Expert
                • Mar 2012
                • 5501

                #8
                Using the formating alone with a numeric-long field will still allow the use of the negative sign while preventing the use of alpha and most other non-numerics; thus a combination of the format mask as you suggested and the validation rule ">=0" would allow "000000" thru "999999" in that even if the user enters only a numeric "5" the formating would give "000005" and preventing the use of a negative.

                In this case, if I understand OP correctly, then he needs to prevent an empty entry, check for a positive, and use the validation rule instead of the mask. All of this is covered in the link I provided.

                As this is almost a basic Access homework assignment, I must ask MMWIT to please post/clearly describe your efforts before we go any further.

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32637

                  #9
                  I think you may be mistaken there Z :-(

                  A formatted result would not change the underlying value as an InputMask would, and would not give the required results. The question asks for a Mask, and I believe an InputMask (of 000000) is the only fully appropriate answer. I would expect the field used to be of type String and of length six, rather than any type of numeric field at all.

                  Comment

                  • zmbd
                    Recognized Expert Moderator Expert
                    • Mar 2012
                    • 5501

                    #10
                    Neopa,
                    Why would you expect a text-classed field instead of a numeric?
                    OP: be fix 6 numbers
                    It is illogical to store numeric information within a text-classed field.

                    As for which of us has a valid statement/solution. This is answered as a "both/and" not an "either/or" given the correct context as follows:
                    My statement is true given a numeric-long field.
                    Your statement is true given a text field.
                    -> I have tested this in V2010 just to see what was what, in that if you had a valid statement within a numeric field then I’d be in serious poop with some of my databases as I have literally thousands of entries that depend on the validation rules being correct and we'd be in serious trouble under ISO certifications if there was something wrong with how I've implemented these at the table level (ok, deep breath, happy place, I'm in my happy place, no bad ISO auditors today, Ice-cream and butterscotch, hot fudge...hmmm – ROTFL – no seriously, there’d be a very un-happy hour or three in my supervisor’s office if something was wrong.)

                    :-)

                    SO, My reply was based upon OP's post #5 which leads me to, two things, that OP is using a numeric field, and that OP has placed the formatting string (if used) and the validation strings in the wrong place... if at all, and has used the wrong string.

                    Comment

                    • NeoPa
                      Recognized Expert Moderator MVP
                      • Oct 2006
                      • 32637

                      #11
                      Originally posted by Z
                      Z:
                      Why would you expect a text-classed field instead of a numeric?
                      Because it's common practice to use formatted number strings in IDs. Certainly not universal, but quite prevalent nevertheless. The benefits are that software is often designed to work with strings of a certain length. Reading through data of varying lengths can be harder on the brain. Invoice Numbers, for instance, are often text strings of n digits formatted with leading zeroes.

                      Bearing in mind the OP is no scholar of English, I'm not sure you can read too much into their comments in post #5. I really don't see where you find support, in there, for the idea the field is numeric, but whatever you glean from that is hardly reliable as the OP is clearly struggling to express themselves precisely in a foreign language.

                      Anyway, get back to your happy place, as I'm not here to cast aspersions on your logic, or even suggest your solution doesn't work. I merely believed that your understanding of what the OP actually wanted, was mistaken. That seems to me perfectly reasonable as we are all struggling to get a clear picture with the meagre crumbs of reliable information contained in their posts. That is not to criticise them for that. Asking technical questions in a foreign language is particularly difficult as we know from how many who fail so badly even when asking in their own language.

                      So, I have no doubt of your competence. I have no doubt that what you use works in the situations you've used them in. I merely doubt that those situations are the same as what the OP's asking about. Clearly you disagree (which surprises me if I'm honest), but I don't see that should necessarily be a problem. We may never find out what the OP really wants, but both solutions are visible in the thread, and if they don't both exactly match the question then they are still both valid in certain situations, so anyone reading the thread has an extra solution to make up for the lack of any meaningful question. A bargain in anyone's language.

                      In conclusion - ice cream served with a steaming hot portion of butterscotch fudge!
                      Last edited by NeoPa; Jan 29 '13, 02:01 AM.

                      Comment

                      • mmwit
                        New Member
                        • Jan 2013
                        • 15

                        #12
                        Set Schork thanks, its been solved

                        and Thank you all dears I have found the correct answer, and the problem is solved

                        Comment

                        Working...