Issue with Access 2010 and date picker

ccices

New member
Local time
Today, 01:09
Joined
Jul 20, 2011
Messages
1
I am using the date picker built in function on an unbound text box.
In the text box propertyI set the format to short date and the show picker for dates.

When I enter a string or a non date number, the error "You have entered invalid data blah blah blah" fires. I would like to change this to my own message and remove the offending data and allow the user to reenter the requested information.

The problem is, even though I can trap the error on the forms on error event (error 2113) and send my own message and undo the text - the standard error message still fires.

I can't seem to resolve this. Here is the code I have to trap the error on the on error event of the form.
Code:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Select Case DataErr
    Case 2113
    Dim varRet
    varRet = MsgBox("You must enter a date in text box!", vbOKOnly)
    If varRet = vbOK Then Me.Text0.Undo
      
    Case Else
      MsgBox "The form error, " & DataErr & " has occurred.", vbOKOnly, "Error"
  End Select
 
End Sub

attached is a sample of this error on a form. Enter a date or null and leave control all is fine.. enter a string and watch the fun.

I must be missing something.. any thoughts?
 

Attachments

You have to set the Response pararmeter to kill the error message.

Code:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Select Case DataErr
    Case 2113
    Dim varRet
    varRet = MsgBox("You must enter a date in text box!", vbOKOnly)
    If varRet = vbOK Then Me.Text0.Undo
    [COLOR="Red"][B]Response = acDataErrContinue  [/B][/COLOR]    Case Else
      MsgBox "The form error, " & DataErr & " has occurred.", vbOKOnly, "Error"
  End Select
 
End Sub
 
I thoroughly recommend the accessdatepicker created by
' Copyright (c) 2003 Brendan Kidwell
' The latest version of this software can be found at
' www dot glump dot net/content/accessdatepicker/
It is an amazing bit of software; and easy to adapt to your needs.
 
I have a question about the Date picker...is it possible to keep it always visible when the form loads ? Without the user clicking in the text box ?
 

Users who are viewing this thread

Back
Top Bottom