Customized Error Messages

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have 3 fields on my main form that are required fields, what I would like
to do is have a custom error
message that would say which fields need populated: ex "Customer Number and
Region must be completed"
Thanks
 
hi
Put something like this at the beginning of your code.

If IsNull(Me!txtfield1) Then
msgbox("enter something in filed1.")
me.field1.setfocus
Exit Sub
Else
If IsNull(Me!field2) Then
msgbox("enter something in filed2.")
me.field2.setfocus
Exit Sub
Else
If IsNull(Me!field3) Then
msgbox("enter something in filed3.")
me.field3.setfocus
Exit Sub
End If
End If
end if
Unless the user put data in all of the three fields, they
will never get past this code sniplet because you exit sub
if they don't.
 
Thank you.

hi
Put something like this at the beginning of your code.

If IsNull(Me!txtfield1) Then
msgbox("enter something in filed1.")
me.field1.setfocus
Exit Sub
Else
If IsNull(Me!field2) Then
msgbox("enter something in filed2.")
me.field2.setfocus
Exit Sub
Else
If IsNull(Me!field3) Then
msgbox("enter something in filed3.")
me.field3.setfocus
Exit Sub
End If
End If
end if
Unless the user put data in all of the three fields, they
will never get past this code sniplet because you exit sub
if they don't.
 
Back
Top