Results 1 to 7 of 7
  1. #1
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    111

    Clear textbox after input message pops up.

    I have a data entry subform in Access 2010 that has several textboxes with input masks. When OK is selected after the system's default input error message appears, I would like the value in the textbox to reset to null. I am unsure how to accomplish this. Suggestions anyone?
    Last edited by newbieX; 01-03-2017 at 05:58 PM. Reason: clarify message is input error message

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    how about the ON ERROR event,
    txtbox = null

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Since you want this to happen for multiple Controls that use Input Masks, I'd roll my own error message, using the Form_Error event, like this

    Code:
    Private Sub Form_Error(DataErr As Integer, Response As Integer)
    
    If DataErr = 2279 Then  'Data entered is not appropriate for the Input Mask
    
     Response = MsgBox("Data Entered Must Be Appropriate!", vbExclamation, "Inappropriate Entry")
     Response = acDataErrContinue
     Me.ActiveControl.SelStart = 0
     Me.ActiveControl = Null
     
    End If
    
    End Sub


    If need be, the message popped can be modified depending on which Control the error occurs on. Fi you need help doing that we can help there, too.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    111
    The code worked great for some of the controls but it did not trigger the time input mask. I am assuming this is a different error number. How can I track down what error number is triggered so I can be sure all correct instances get captured?


    Quote Originally Posted by Missinglinq View Post
    Since you want this to happen for multiple Controls that use Input Masks, I'd roll my own error message, using the Form_Error event, like this

    Code:
    Private Sub Form_Error(DataErr As Integer, Response As Integer)
    
    If DataErr = 2279 Then  'Data entered is not appropriate for the Input Mask
    
     Response = MsgBox("Data Entered Must Be Appropriate!", vbExclamation, "Inappropriate Entry")
     Response = acDataErrContinue
     Me.ActiveControl.SelStart = 0
     Me.ActiveControl = Null
     
    End If
    
    End Sub


    If need be, the message popped can be modified depending on which Control the error occurs on. Fi you need help doing that we can help there, too.

    Linq ;0)>

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Nope...error number is the same anytime data in a Control with an Input Mask is not entered appropriately...and I cannot reproduce your problem, in v2007. The code I gave works regardless of the Datatype of the Control/Field involved. Other than the DateTime Control being corrupted (simple fix is to delete it/recreate it) can't really offer much else unless I can lay hands on your file. If you'd care to save it in Access 2007 format (or Access 2003 format, that would allow even more members to help) I'd be happy to look at it.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    111
    The error number I used to capture the error for the time mask was 2113.Not sure why but it works now.

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Error 2113 has nothing to do with an invalid Input Mask entry...it is popped when incorrect data type is entered. It'll pop, in this case, if the data entered isn't a valid for a DateTime Field, which could be caused by having an incorrect Mask, I suppose, or simply by ignoring the Mask and entering non-valid data. Possibly, if both errors occur, i.e the data entered violates the Input Mask and is incorrect for the Datatype, the 2113 error will pop first, or maybe only it will pop; not sure how the Access gnomes handle it when two errors occur simultaneously!

    Glad you've got it working for you, at any rate!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 09-19-2013, 08:04 AM
  2. Message Box and User Input
    By MintChipMadness in forum Programming
    Replies: 3
    Last Post: 01-10-2013, 05:18 PM
  3. Replies: 3
    Last Post: 09-20-2011, 11:54 AM
  4. Input Value based on another textbox value
    By dude19 in forum Access
    Replies: 2
    Last Post: 06-30-2011, 03:48 PM
  5. Textbox will not allow input
    By cwf in forum Forms
    Replies: 0
    Last Post: 04-04-2008, 04:08 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums