custom input mask msgs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Trevor2007
    New Member
    • Feb 2008
    • 68

    custom input mask msgs

    I would like to allow the user to enter an input mask for a field and have the appropriate error message display if the citeria isn't met.ie: input mask = 99AA99"A""B"
    the message box would then display "formate must be ' 12AB34AB"
    or if the input mask was 9A990"C" the message would be "formate must be '1A23C', or ' 1A234C'"
    Note: inputask 'A' is any letter Ucase, and 'a' is any letter lCase, I would like to diferenchiant between the two for msg formating
    sorry not formated right for tags but don't think they are needed here
    thanks for helping
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by Trevor2007
    I would like to allow the user to enter an input mask for a field and have the appropriate error message display if the citeria isn't met.ie: input mask = 99AA99"A""B"
    the message box would then display "formate must be ' 12AB34AB"
    or if the input mask was 9A990"C" the message would be "formate must be '1A23C', or ' 1A234C'"
    Note: inputask 'A' is any letter Ucase, and 'a' is any letter lCase, I would like to diferenchiant between the two for msg formating
    sorry not formated right for tags but don't think they are needed here
    thanks for helping
    Here is the code to replace the Access Standard Error Message for Input Mask Validation Errors with your own. This only applies for a single Field with an Input Mask! If multiple Fields are involved, the code would be different.
    [CODE=vb]
    Private Sub Form_Error(Data Err As Integer, Response As Integer)
    Const conINPUT_MASK_V IOLATION As Integer = 2279

    If DataErr = conINPUT_MASK_V IOLATION Then
    MsgBox "Input Mask Violation. Blah...Blah...B lah..."
    Response = acDataErrContin ue
    End If
    End Sub[/CODE]

    Comment

    • Trevor2007
      New Member
      • Feb 2008
      • 68

      #3
      Thanks for the repy,
      but I am already using that code to produce custom input mask messages,
      here what I am trying to do, present the user with a form that will allow them to create/edit the input mask and then the error message would automticly modifiy itself to corispond wth the input mask (see OP for examples)
      Thanks

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by Trevor2007
        Thanks for the repy,
        but I am already using that code to produce custom input mask messages,
        here what I am trying to do, present the user with a form that will allow them to create/edit the input mask and then the error message would automticly modifiy itself to corispond wth the input mask (see OP for examples)
        Thanks
        It's fairly easy to pro-grammatically modify the Input Mask of a Field via a Form Interface, store the new Mask in a Table with some reference to the associated Field Name, then use a DLookup in an Error Message to properly reference the Mask for a given Field. In my opinion, and I'm sure most, if not all, of the other Experts/Moderators will agree, it would be very unwise to give this capability to a User of your Database.

        Comment

        • Scott Price
          Recognized Expert Top Contributor
          • Jul 2007
          • 1384

          #5
          An input mask exists to restrict and focus the data entry. It exists for data validation. I agree with ADezii. Giving the users the ability to change this on the fly negates the primary purpose for which it exists in the first place!

          I would need a very compelling reason before being able to suggest that this is a good idea :-)

          Regards,
          Scott

          Comment

          • missinglinq
            Recognized Expert Specialist
            • Nov 2006
            • 3533

            #6
            I have to agree with ADezii here, allowing end users this kind of design changing ability is just plain wrong! The whole point of using an Input Mask is to insure that entered data is in the correct format. Why would you allow the user to to decide the correct format and why would you allow more than one format?

            Linq ;0)>

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32634

              #7
              I can't imagine a situation where it might be appropriate for a user to choose the input mask directly, however, I don't know your situation so I won't be any more definite than that for now.

              However, while changing the mask is fairly straightforward , and changing the error message appears also to be simple in itself, creating a message that intelligently matches the mask without simply displaying the mask within it (in other words parsing the mask itself) would be another job again.

              IS there a really good reason for this Trevor?

              Comment

              • FishVal
                Recognized Expert Specialist
                • Jun 2007
                • 2656

                #8
                Hi, Trevor.

                As far as I've understood your intension, you are trying to figure out a logic for validation of input mask string provided by user. Depending on expected "intelligen ce", the code may be rather sophisticated. I suggest, just for starters, provide user with opportunity to choose from predefined masks only.

                Regards,
                Fish.

                Comment

                • Trevor2007
                  New Member
                  • Feb 2008
                  • 68

                  #9
                  ok, I see most of you say and in most situations I would agree about not allowing users to adjust an input mask, but here is my situation, and don't see much of anyother option other then to have predefind input masks. Anyway the reason behind input mask adjusting by the enduser( is actualy going to be the assingnd Db admin(I have the back end setup with datasheet(false tables) linked to the real tables so I can further controle what is done there.
                  back to input mask editing is because the input mask is a mask for an individual's ID Number, and since the IDNumber formate may verry(because I'm settiny this DB up so more then one entity may be able to mod it to their needs through an interface). I only know 1 input mask which is ##### or ######
                  I hope this made my logic of why I would even want to allow the end user this option clearer.
                  thankyou for all input, I would like feedback on this and suggestions.

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32634

                    #10
                    1. Is the InputMask property to be changed in the database or just for the current session?
                    2. How many fields are you considering setting this up for?
                    3. What logic do you intend to use for parsing the InputMask entered, into your error message?

                    Comment

                    • ADezii
                      Recognized Expert Expert
                      • Apr 2006
                      • 8834

                      #11
                      Originally posted by Trevor2007
                      ok, I see most of you say and in most situations I would agree about not allowing users to adjust an input mask, but here is my situation, and don't see much of anyother option other then to have predefind input masks. Anyway the reason behind input mask adjusting by the enduser( is actualy going to be the assingnd Db admin(I have the back end setup with datasheet(false tables) linked to the real tables so I can further controle what is done there.
                      back to input mask editing is because the input mask is a mask for an individual's ID Number, and since the IDNumber formate may verry(because I'm settiny this DB up so more then one entity may be able to mod it to their needs through an interface). I only know 1 input mask which is ##### or ######
                      I hope this made my logic of why I would even want to allow the end user this option clearer.
                      thankyou for all input, I would like feedback on this and suggestions.
                      1. I strongly feel that FishVal's approach is the only valid one should you decide to implement this (User selects from a predefined list of Input Masks).
                      2. Are the Input Masks to be applied to a Field in a Form or in a Table? If they are defined in a Table, the corresponding Field in a Form will not inherit the Mask.
                      3. What is the List of acceptable Input Masks along with their descriptions?
                      4. You need Input Mask Validation Errors to correspond to the existing Input Mask at the timer the Error occurs. The Field Names and Masks can be stored internally in a Hidden Table, while the name of the Control for which the Input Mask Error occurred can be retrieved by Screen.ActiveCo ntrol.Name.

                      Comment

                      • Trevor2007
                        New Member
                        • Feb 2008
                        • 68

                        #12
                        The input mask is for 1 field the current input mask is 999990 and msg formate should be 12345 or 123456.
                        this is to be aplied to the field via dlookup and attaching it to a string , the table the value is looked up from is (will be) hidden .
                        II hope this answers everyones questions
                        I am using the input mask validation on active screen to produce custom messages..

                        Comment

                        • NeoPa
                          Recognized Expert Moderator MVP
                          • Oct 2006
                          • 32634

                          #13
                          If you have a table with the acceptable InputMasks held, then you should store the error message in another field of the same table. This will be a far simpler solution than trying to work it out by parsing the InputMask directly.

                          Comment

                          • blad3runn69
                            New Member
                            • Jul 2007
                            • 59

                            #14
                            thank you for the code ADezii
                            the default input mask validation error is pretty ugly for avg user
                            you guys rock!

                            Comment

                            • ADezii
                              Recognized Expert Expert
                              • Apr 2006
                              • 8834

                              #15
                              Originally posted by Trevor2007
                              The input mask is for 1 field the current input mask is 999990 and msg formate should be 12345 or 123456.
                              this is to be aplied to the field via dlookup and attaching it to a string , the table the value is looked up from is (will be) hidden .
                              II hope this answers everyones questions
                              I am using the input mask validation on active screen to produce custom messages..
                              The following solution seems to work very well for what you are trying to accomplish:
                              1. Create a Table named tblMasks with the following Fields:
                                1. [Field_Name] 'will hold the names of all Fields having Input Masks
                                2. [Mask] 'the actual Mask itself '999990', etc.
                                3. [Error_Msg] 'your Custom Error Message for a specific Field
                                4. All Fields are {TEXT} and are 'REQUIRED'
                                5. Populate tblMasks
                              2. Define your Input Masks for your Form Fields that wish to participate.
                              3. Copy and Paste the following code to the Form's Error() Event.
                                [CODE=vb]
                                Private Sub Form_Error(Data Err As Integer, Response As Integer)
                                Dim varErrMsg As Variant
                                Dim strFldName As Variant
                                Dim varInputMask As Variant
                                Dim strMsg As String
                                Const conINPUT_MASK_V IOLATION As Integer = 2279


                                If DataErr = conINPUT_MASK_V IOLATION Then
                                strFldName = Screen.ActiveCo ntrol.Name 'Retrieve Field Name
                                'Retrieve Custom Error Message
                                varErrMsg = DLookup("Error_ Msg", "tblMasks", "[Field_Name] = '" & strFldName & "'")
                                'Retrieve valid Input Mask information
                                varInputMask = DLookup("Mask", "tblMasks", "[Field_Name] = '" & strFldName & "'")

                                strMsg = "Input Mask Error in [" & strFldName & "]" & vbCrLf & varErrMsg & vbCrLf
                                strMsg = strMsg & "Valid Input Mask: " & Nz(varInputMask , "No Valid Input Mask(s) provided")
                                MsgBox strMsg, vbExclamation, "Input Mask Violation"
                                Response = acDataErrContin ue
                                End If
                                End Sub[/CODE]
                              4. Any questions or problems, give us a call.

                              Sample OUTPUT (displayed Error Messages):
                              [CODE=text]
                              Input Mask Error in [txtField1]
                              Valid entries are 12345 or 123456
                              Valid Input Mask: 000009


                              'For Controls not listed in tblMasks
                              Input Mask Error in [cboBlah]

                              Valid Input Mask: No Valid Input Mask(s) provided
                              [/CODE]

                              Comment

                              Working...