ListBox color row based on value in field (1 Viewer)

Rx_

Nothing In Moderation
Local time
Today, 12:18
Joined
Oct 22, 2009
Messages
2,803
Can Access 2010 use VBA to color individual rows in a Listbox?
Access 2010 - This has been asked several times, the answer is to use a repeating form. After searching the Internet for a while this code segment came up. I have not tried it yet.
Does anyone have news, comments or updates about changing the font color for an individual row in the listbox based on a value?
- update: I posted this before going to lunch - this code is not even in the ballpark - it must be for some listbox object outside Access
Still can not find any way. Maybe someone has a good 3rd party Access Listbox control to suggest?
Code:
With Me.ListView1
For Counter = 1 To Me.ListView1.ListItems.Count
        Set Item = Me.ListView1.ListItems.Item(Counter)
        ' Set the variable to the amount
        Amount = Item.SubItems(4)
If Amount <= 500 Or Amount <= 1000 Then
.ListItems.Item(Counter).ForeColor = vbRed
.ListItems.Item(Counter).ListSubItems(1).ForeColor = vbRed
.ListItems.Item(Counter).ListSubItems(2).ForeColor = vbRed
.ListItems.Item(Counter).ListSubItems(3).ForeColor = vbRed
.ListItems.Item(Counter).ListSubItems(4).ForeColor = vbRed
else
'duplicated just make it vbBlack
.ListItems.Item(Counter).ForeColor = vbBlack
.ListItems.Item(Counter).ListSubItems(1).ForeColor = vbBlack
.ListItems.Item(Counter).ListSubItems(2).ForeColor = vbBlack
.ListItems.Item(Counter).ListSubItems(3).ForeColor = vbBlack
.ListItems.Item(Counter).ListSubItems(4).ForeColor = vbBlack
end if
 
Next Counter
Me.ListView1.Refresh
 
Last edited:

Rx_

Nothing In Moderation
Local time
Today, 12:18
Joined
Oct 22, 2009
Messages
2,803
I totally agree. After a good bit of searching, that is the only option, short of a third party list box.
Had false hopes that Access 2010 added a feature.
 

Users who are viewing this thread

Top Bottom