Change Access default error message

  • Thread starter Thread starter Elaine Ellul
  • Start date Start date
E

Elaine Ellul

Hi guys,

Does anybody know how to trap MS Access default errors messages and replace
them with user-friendly ones?
For example, I have a few mandatory fields in my table.
When the user does not enter a value in one of the fields (in the Form
view), I would like to give a friendly message and set focus to that
particular text box.

I have tried using the BeforeInsert form event, without luck.


Any help will be greatly appreciated!

Elaine
 
The form's Before Update event is usually the best place to perform field
validation. Maybe something like:

If IsNull(Me.txtMyTextBox) Then
msgbox "Field needs to be filled in"
Me.txtMyTextBox.SetFocus
End If
 
Hi Bruce,

Many thanks, this works but it doesnt stop access from prompting its default
message. So after I get the first message box "Field needs to filled in", I
still get Access message:

"The field 'tblContacts.Surname' cannot contain a Null value because the
Required property for this field is set to True. Enter value in this field"

Is there a way I can bypass Access' Message or should I just rely on the
form BeforeUpdate code for a required field? (that is, by setting the
Required property to false, in the table design?)

Many thanks,

Elaine
 
I forgot that you have set table-level validation. I don't think you need
both form-level and table-level validation, but if you keep the table-level
validation you should be able to avoid it by adding this before the End If
line:
Cancel = True
 
Thanks again Bruce, that works fine too. I shall keep it that way, both
form-level and table-level validations for now.
Cheers!
Elaine
 
Back
Top