How to create custom Input Mask date msgbox  when none date value is entered in date field

Slimfit
Slimfit used Ask the Experts™
on
I want a custom message that inform the user that wrong data type is entered in "date field" , Instead of the default message that says
"The value you entered isn't appropriate for the input mask  ..... specified for this field"

Thanks

Slimfit
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
Commented:
you can use the On Error event of the form to create the custom message

Private Sub Form_Error(DataErr As Integer, Response As Integer)
    if Dataerr=2279 then
         msgbox "Your message here
    end if
     response = acDataErrContinue
End Sub

you can add more custom message by trapping different type of error with

select case dataerr
    case 2279
            'your custom message
    case  3314
             'your custom message
    case else

end select

for list of errors see this link http://www.fmsinc.com/microsoftaccess/errors/ErrorNumber_Description2007.html
Distinguished Expert 2017
Commented:
I don't ever use input masks for date fields.
1. they prevent the use of the calendar popup
2. they don't ensure that the user entered a valid date
3. they require you to enter a minimum of 6 characters, 8 if you are using a 4 digit year.

I do use input masks for other types of data, just not for dates.  I like my user to be able to enter 3/14 and have the year default.

Author

Commented:
Very helpful

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial