Custom error messages.

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

Does anyone know if the error messages from the system,
such as the message you get when you try to save a record
without a required field populated, can be customized to
tell the user more specifically what to do. Or if you have
a situation where you want to creat a message with a
message box, where do you put the code. I have tried it in
the Field Exit event, the Lost Focus event. I want this
message to pop up if someone exits this text box on the
form without entering data.
 
What if they never enter the field?

I would put some validation code on the button they press when trying to
enter the record - in the On_CLick Event

something like (not tested)

Sub btnOK onclick()
if nz(me.txtNeedData,"") = "" then
me.txtNeedData.setfocus
exit sub
end if
End Sub

HTH
 
Eric

One way you can run a series of validation checks on a form is to use the
form's BeforeUpdate event to check each field/combinations of fields.
 
Eric,

In the design view of your table, you can enter this in the Validation
Rule property of the field(s) concerned...
Is Not Null
.... and then in the Validation Text property, you write the message you
want to have pop up if they have not entered anything.

However, this will only "kick in" when you try to finish the record on
the form. If you literally want this to be checked, as per your post,
at the point where the user exits the textbox, this can also be done,
e.g. on the Exit event...
If IsNull(Me.MyTextbox) Then
MsgBox "You can't leave this empty!", , "Data required"
Cancel = True
End If
 
Back
Top