Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlight multiple labels on form from text box

Status
Not open for further replies.

air1jcw

Technical User
Jan 23, 2003
30
US
I have multiple labels on a form. I would like to be able to enter a "IID" into a text box, and then after update, highlight the labels (either text color change, or bold) that are equal to the "IID" entered in the text box.

Can ya point me in the right direction??
Thank you in advance!!!
 
Hi,

This may help point you in the right direction...

Assume that your textbox is called txtOne then in the AfterUpdate of the textbox you can have something like...

Dim ctrl As Control

'loop through all form controls
For Each ctrl In Me.Controls
'if control is a label
If TypeOf ctrl Is Label Then
'if the text in the label caption = text in textbox
If ctrl.Caption = txtOne.Text Then
'set label Text Color to Blue
ctrl.ForeColor = vbBlue
End If
End If
Next ctrl

Hope this helps.



There are two ways to write error-free programs; only the third one works.
 
Again air1jcw,
use conditional formatting.
I'm not sure if the loop procedure will work, It sounds interesting but I don't know.
When changing formatting on a form, it changes the control on all the records. Thus, you must use OnCurrent event for the form...or conditional formatting.
But, I've never tried the loop procedure?
Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top