invalid data entry

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mseo
    New Member
    • Oct 2009
    • 183

    #1

    invalid data entry

    hi,
    I have a form within access 2003 database
    this form contain a textbox assigned for entering the hire date (date/time)
    but when I enter a text entry to this field by mistake I get a prompt that the data you entered isn't valid for this field
    the point is how can i handle this using vba code
    thank you for any help you may provide me.
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    Here's an example I copied from somewhere that you can alter or add to to suit your needs. You may have to search for the appropriate integer for the error you are trying to handle.

    Code:
    'This changes the Input Mask default message******************
    Private Sub Form_Error(DataErr As Integer, Response As Integer)
      Const INPUTMASK_VIOLATION = 2279
      If DataErr = INPUTMASK_VIOLATION Then
        MsgBox "Invalid input."
        Response = acDataErrContinue
      End If
    End Sub

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      How do you want it to be handled. That's not a very clear indication of what you want. Please try to explain what you mean.

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        The error for this is 2113, so use that in place of the 2279 in Chip's code, assuming that Chip has the right idea and you just want to have a more user-friendly error message. If your need is for something else, then you'll have to give us a more detailed explanation of what you want to do, as NeoPa said.

        Linq ;0)>

        Comment

        • mseo
          New Member
          • Oct 2009
          • 183

          #5
          hi,
          this code is running good for this kind of errors
          but when I enter a text entry to numeric field the msgbox appears for the user "invalid input" , but the entry I enter to the field still in the field
          I just want to handle this as you provided me but I need one more step to make the form user-friendly this step is when i click on the ok button in the msgbox i want the input i inserted to be removed out of the field
          thank you all

          Comment

          • ChipR
            Recognized Expert Top Contributor
            • Jul 2008
            • 1289

            #6
            From a user-friendly perspective, I'm not so sure you want to just wipe out the input. Consistency is key for a friendly interface, and most programs we use will hilight the error so that it can be fixed rather than delete it.

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32669

              #7
              That's very good advice from Chip. I would give that serious consideration.

              Comment

              • mseo
                New Member
                • Oct 2009
                • 183

                #8
                thanks
                I meant not to delete the input but let's assume that the user entered a text in numeric field error msgbox will be appeared for him, and when the user click ok in this msgbox the text he had entered would be in the field so i just want: when the user insert a text in numeric field get a msgbox and when click ok wipe out the the text that the user inserted
                i need to do so because what a bout if the user click exit without adding any new record he will get error msg but if i wiped it out the user wouldn't get any type of error
                thanks for advice ChipR

                Comment

                Working...