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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Font Colors in a List box based on a value.

Status
Not open for further replies.

lreedy

Programmer
Jan 4, 2001
8
0
0
US
I have created a list box that displays the items in an item master table. Can I have individual lines(records) in the list display in different colors based upon a value of a field in the item master? For instance if QTY on hand is zero, I would want that item to appear in red.

Do I need a subform for this instead to have it work?

I am VERY new to this so patience please.

I found the following code in an old post and I am unsure if it will work.

Thanks!

_____________
let us say that you have a combo box called [States] and a text box called [Text2], your code should be like
follows:
Select Case States
Case "AL" 'state of Alabama
States.ForeColor = vbYellow
Text2.ForeColor = vbYellow
Case "NY" 'State of New York
States.ForeColor = vbBlue
Text2.ForeColor = vbBlue
Case Else
States.ForeColor = vbBlack
Text2.ForeColor = vbBlack
End Select
Alaa Sallam

Let als
 
That type should work. The key is where u put it. You will need to put it under the "On Format" section of the form I believe. This will work or it wont. I cant remember when I did it if I finally just did it on the report and not the form. But whichever I did, where I put it made the big difference.

I do know that it must be called from the On Format section though.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top