Preventing Form Error (1 Viewer)

daveUK

Registered User.
Local time
Today, 14:16
Joined
Jan 2, 2002
Messages
234
One quick question

Hi guys

I have a textbox on the form that allows the user to enter a date in the format dd/mm/yyyy. I've used an input mask to show the user how the date should be entered and it appears like this:

__/__/____

This works ok, but only until the user enters the date in the wrong format. At this point Access displays an error message. How do I disply my own custom error message. I've tried the do.cmd Set Warnings False on the AfterUpdate and LostFocus properties, but it doesn't seem to work.

Thanks

Dave
 

jaydwest

JayW
Local time
Today, 07:16
Joined
Apr 22, 2003
Messages
340
Input Mask Errors produce a Form Error. Just when you thought you knew everything about errors, there are now Form Errors. You can trap this error on the Form.Error Event.

Here is some sample code

If DataErr = 2113 Then
myM = "FIX THE STUPID DATE DUMMY."
MsgBox (myM)
Response = 0
End If

You may also want to test for the field so you don't inadvertently send the user a message to fix the date on a phone number field.

Good Luck. Let me know how it goes.
 

daveUK

Registered User.
Local time
Today, 14:16
Joined
Jan 2, 2002
Messages
234
great stuff

Thanks Jay it works. I never thought about the form.error event.

Dave
 

Users who are viewing this thread

Top Bottom