problems with date input mask

pauly

Registered User.
Local time
Today, 19:32
Joined
Jul 8, 2002
Messages
49
Hi i have realised that there are a few problems when using an input mask for a date field. The input mask i am using is 99/00/00;0;_ This works fine if a correct date is entered and if a none date type is entered. But if the user accidently enters a date such as 35/12/12, which should not be allowed, as there arent 35 days in december (i am in Australia, so this is the date format) instead of an error appearing, this date is transformed, and stored, as 12/12/35. This could lead to problems if the user doesnt pick up that they have entered this invalid date, is there any way to stop this from happening.

btw. i have also set the format of the field that this date is being stored in to Date/Time.

Thanks
 
I've found myself entering the wrong year, usually around February for some strange reason, so I use this

Private Sub DatePurch_BeforeUpdate(Cancel As Integer)
Dim Msg, Style, Title, Response, MyString
If DatePart("yyyy", Me.DatePurch) <> DatePart("yyyy", Date) Then
Beep

Msg = "The date you have entered is not the current year is this correct ?"
Style = vbYesNo + vbExclamation + vbDefaultButton1
Title = "Date verification"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
Exit Sub
Else
Cancel = True
Me.Undo
End If
End If

End Sub
 
Instead of using 99/00/00 use dd/mm/yy as the mask
 

Users who are viewing this thread

Back
Top Bottom