Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Verify date is valid date - override MsAccess97 message 1

Status
Not open for further replies.

PurpleUnicorn

Programmer
Mar 16, 2001
79
US
I have an application in ACCESS97. I need to verify that a user entered date is a valid date and I would like to override the built in error message . (ie, my message would appear if user enters 13/13/99)

I have attempted to enter a validation rule/text - it is ignored.

I have also tried putting message boxes on the after_update, on_exit and lost_focus events for the control - the messages are not displayed.

Access seems to be doing the validation before any of the events fire. I am very frustrated.
(I need to do this because the customer thinks the Access message is not user-friendly)

Thanks,
Nancy
 
Since this particular error is not a runtime error you will have to catch it in the Form's ErrorEvent. The error number for your particular error is 2113, thus you would code as follows:

Private Sub Form_Error(DataErr As Integer, Response As Integer)

If DataErr = 2113 Then
'the above line catches your error.
MsgBox "A much nicer message goes here!"
Response = 0
'the above line tells access not to show the system message.
MyTextBox.Undo
'the above line tells access to undo the incorrect typing.
End If

End Sub

Hope this helps ljprodev@yahoo.com
Professional Development
MS Access Applications
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top