Loop through TextFields,

Hello,
Is it possible to loop through a window’s TextFields, and check for any which are empty - and if so, change the TextField’s background colour?

I have looked in the language reference but can’t seem to find anything relevant.

Thank you.

dim i as integer
dim tf as textfield
dim ctrl as control
// assume "ME" is the window in question
  For i=0 To Me.ControlCount-1
    ctrl=Me.control(i)
      If ctrl IsA TextField Then .....
        tf=TextField(ctrl)
            if tf.text<>"" then do something
      End If
  Next i

Thanks Dave :slight_smile:

So my code now looks like this:

[code] dim i as integer
dim tf as textfield
dim ctrl as control

For i=0 To Window1.ControlCount-1
ctrl=Window1.control(i)
If ctrl IsA TextField Then
tf=TextField(ctrl)
if tf.text="" then
tf.HasBackColor = True
tf.BackColor = &c990000.
End If
end if
Next i[/code]

One change: use “Self” in place of “Window1” that way your code does not needlessly rely on the window name.