Required field custom message?
I am working on making certain fields required in my tables and forms.
Under the General tab in ms access 2003 I have updated the required property to yes.
Everything is working and when I test it leaving data out of the required field I get the message saying
"The field tbl_student.FirstName cannot contain a NULL value because the required property for this field is set to TRUE. Enter a Value in this field."
This message is a bit ounclear for users who might not understand tbl_student.FirstName.
How do I make my own message. "Please enter a your first name" or something along those lines.
Thanks in advance
June 16th, 2011, 09:33 AM
You'll have to catch the relevant error number and handle it as you wish, likely in a Form_error sub.
Private Sub Form_Error(DataErr As Integer, Response As Integer)
' sub to catch all form errors
Const errRequired = 3314
'3314 is the error number for missing mandatory data.
If DataErr = errRequired Then
' if the current error is 3314
MsgBox ("Enter your first name")
' custom error message
Response = acDataErrContinue
' dont show the generic message
Response = acDataErrDisplay
'Not a missing data error, so just show generic message.