Check date format

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a function that can check the number of days in a month? For example I have a unbound date control. If I enter 31/06/2004, the function will alert there is no 31st in June, or there is no 29th in Feb 2003.
 
Is there a function that can check the number of days in a month? For example I have a unbound date control. If I enter 31/06/2004, the function will alert there is no 31st in June, or there is no 29th in Feb 2003.

If you set the unbound control's Format property to a valid date
format it will alert you if an incorrect date value is entered in the
control.
 
Thanks and this is exactly what I am facing too. In my system, I control all error and display error messages using codes. I would to like do the same for standardization.

Any idea?
 
Thanks and this is exactly what I am facing too. In my system, I control all error and display error messages using codes. I would to like do the same for standardization.

Any idea?


You can find the error number by simply coding the Form's Error event:

Private Sub Form_Error(DataErr As Integer, Response As Integer)
MsgBox DataErr
Response = acDataErrContinue
End Sub

Open the form and intentionally create that Date entry error.

Then change that code to trap the error (which is 2113) in the Form's
Error event:

Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 2113 Then
MsgBox "Please enter a valid date"
Response = acDataErrContinue
End If
End Sub
 
Back
Top