-
I have a GoFind Command button that fills in all of the text, combos, etc, when clicked. There are tons of objects to be filled and I am trying to fill the ones that do not have a value entered with a different color and "Input". Is there a quicker way than the following code to fill all of these in or do I really have to go thru each object and fill it in?? Early Thanks.
If IsNull(tb!TransAssnmtDate) = True Then
txtDateAssnd.Text = "Input Date"
txtDateAssnd.ForeColor = vbRed
Else
txtDateAssnd.ForeColor = vbBlack
txtDateAssnd.Text = (tb!TransAssnmtDate)
End If
If IsNull(tb!transCompleted) = True Then
txtTransCmpleted.Text = "Input Date"
txtTransCmpleted.ForeColor = vbRed
Else
txtTransCmpleted.ForeColor = vbBlack
txtTransCmpleted.Text = (tb!transCompleted)
End If
-
You might try something like this:
Dim obj As Control
For Each obj In FormName.Controls
If TypeOf obj Is TextBox Then
If IsNull(obj.text) Then
'...
Else
'...
End If
End if
Next
you can also re-use the code by changing the type of the control (eg change TextBox into CheckBox and the code works for all checkboxex)
[This message has been edited by Frederik Gekiere (edited 02-02-2000).]
-
Hey Frederik or someone else who is looking, Thanks but I also am joing these textboxes to fields in a DB and if the object is not null then it will be filled with whatever field it matches with in the DB. Is it still possible to fill in all of them in a quicker way. I shold have mentioned the DB part at first. Thanks.