Ummm, yeeesssss. See? There I go
also making assumptions. Yes, I assumed text would be entered into all the textboxes.
Actually, for a good look at error trapping empty values see the attached files in Seamus' thread on two variables. It is not perfect, but it is good.
Why not perfect?
Because it only gives back error messages one at a time. If there are five missing data chunks the error trapping routine executes five separate times. The user gets five separate error messages.
Long time programmers know that perfect error trapping (if possible at all) sometimes takes up to 50% of ALL time spent on a project.
As a suggestion for increasing the user view, within the error trapping routine you make an array of all offending controls. Pseudocode:
For each control in Me.Controls
If control is visible (so it is supposed to be used)
If control = "" (and it is supposed to have something)
Redim Preserve ErrMessages(j)
ErrMessages(j) = control name
Now you have a listing of controls that should NOT be "".
To continue, you can go a couple of ways. First, translate the control name to an user understandable name.
Eg: txtSurName = "surname"
Do this with a Function, say MakeSense.
Dim msg As String
for var = 0 To Ubound(ErrMessages)
msg = msg & "The field " & _
MakeSense(ErrMessages(var)) & _
"is empty. This is a required field."
next
Msgbox msg
Now the users gets a full list of ALL empty textboxes.
Yadda yadda yadda. In mine I have specific error messages for each control and build the message linking the error text for a control.
Are we having fun yet??????