I tried this code but it appears to go from box to box based on the
boxes time of creation.
Is it possible to reset creation time so the loop checks from top to
bottom without skipping around.
Private Sub Command49_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
If ctl.Tag = "Verify Data" Then
If ctl.Value > "" Then
ctl.Value = ctl.Value
Else
MsgBox "Missing Data"
ctl.SetFocus
Exit For
End If
End If
End If
Next
End Sub
Thanks, Rick
Suggest doing a Cut and then Paste of the textboxes in your form. Perhaps
that will reset the
creation time of the textboxes in top to bottom order.
HTH. Linda
"2D Rick" <rbro...@compuserve.com> wrote in message
news:1132269919.8...@g43g2000cwa.googlegroups.com...
Thanks for the reply
RICK
I think there was a thread in this NG not long ago discussing
this. If I'm not mistaken, I think the answer was no (at least
for practical purposes), think of collections as unordered.
Here's one suggestion
- use a naming convention on the boxes that makes it
possible to loop them as "control array", i e
txt1, txt2, txt3..
for lngcounter = 1 to N
msgbox me.controls("txt" & cstr(lngcounter)).value
next lngcounter
--
Roy-Vidar
The code I usually use to loop through textboxes is thus:
Dim ctl As Control
For Each ctl In frmFormName.Controls
If ctl.ControlType = acTextBox Then
If ctl.Text="" Then
MsgBox "Textless"
End If
End If
Next ctl
The tab order is set from top to bottom and works as planned.
The textboxes were created from top to bottom on day one.
Since then I have shuffled the placement of the text boxes to help in
input flow of data.
They must have some hidden reference in controls collection????????
Rick
Give it try
> Suggest doing a Cut and then Paste of the textboxes in your form.
> Perhaps that will reset the
> creation time of the textboxes in top to bottom order.
The z order is set by when you put the control on the form, so if
you bring the control to front (or sent id to back) you are moving
it in the z order.
I also think the basic task being performed is *wrong* in the first
place. If the value is required, then don't allow the record to be
saved until all fields are filed out. That can be done by having the
AfterUpdate event of each of the required controls check all the
required fields and enable the SAVE button when everything is filled
out. This would include informing a user that a required field can't
be Null if they delete the value in a required field.
I just think it's user-hostile to present multiple validation
messages like this, one field after the other. Instead, it's better,
seems to me, to tell the user that all required fields have not been
filed out, tell them which ones are missing, and then dump them back
to the form, rather than hitting them with message box after message
box.
--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
ps. your colorful skirmishes with the prickly bunch lighten my day.
lblErrorMessage=str
This way, if the user leaves both boxes empty, they are presented with
the following message:
Please enter a value for txtBox1.
Please enter a value for txtBox2.
At the same time, and without extra code, if the user leaves only one
box blank, he will still get the appropriate message.