Gimpster
Jan 14th, 2000, 05:40 AM
What I'm trying to do is to read through a form with a bunch of text boxes that have matching labels. I want to check to see if the text box is empty and if so, then I want to change the label's forecolor to red. Here is my code:
Dim x as Object
For Each x In Me.Controls
If Left(x.name, 3) = "txt" Then
If x.name <> "txtdate_terminated" Or x.name <> "txtemp_mi" Or x.name <> "txtnotes" Then
If x.Text = "" Then
Dim name As Variant
name = Mid(x.name, 4)
name = "lbl" + name
name.ForeColor = &HFF&
End If
End If
End If
Next x
I also tried defining the name variable as a string and defining another variable as an object and then setting the object equal to the string, but that didn't work. All of my text boxes' names begin with "txt" and all of my labels' names begin with "lbl". So all I need to be able to do is to replace the "txt" with "lbl". Any suggestions are welcome. Thank you.
------------------
Ryan
Dim x as Object
For Each x In Me.Controls
If Left(x.name, 3) = "txt" Then
If x.name <> "txtdate_terminated" Or x.name <> "txtemp_mi" Or x.name <> "txtnotes" Then
If x.Text = "" Then
Dim name As Variant
name = Mid(x.name, 4)
name = "lbl" + name
name.ForeColor = &HFF&
End If
End If
End If
Next x
I also tried defining the name variable as a string and defining another variable as an object and then setting the object equal to the string, but that didn't work. All of my text boxes' names begin with "txt" and all of my labels' names begin with "lbl". So all I need to be able to do is to replace the "txt" with "lbl". Any suggestions are welcome. Thank you.
------------------
Ryan