I am using Access 2000 which has a form containing 1 ListView box. I am using the following code to color the text within the ListView:
Function FormatColors()
Dim Item As ListItem: Dim Counter As Long: Dim Color As String
For Counter = 1 To [Forms]![frm_Schedule_list].ListView1.ListItems.Count
Set Item = [Forms]![frm_Schedule_list].ListView1.ListItems.Item(Counter)
Priority = Item.SubItems(10): With [Forms]![frm_Schedule_list].ListView1
If Priority = 0 Then 'Red
.ListItems.Item(Counter).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(1).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(2).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(3).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(4).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(5).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(6).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(7).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(8).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(9).ForeColor = 255
End If
Next Counter
Exit Function
I would like to know if it is possible to format the background color of the text also maybe something like this
Function FormatColors()
Dim Item As ListItem: Dim Counter As Long: Dim Color As String
For Counter = 1 To [Forms]![frm_Schedule_list].ListView1.ListItems.Count
Set Item = [Forms]![frm_Schedule_list].ListView1.ListItems.Item(Counter)
Priority = Item.SubItems(10): With [Forms]![frm_Schedule_list].ListView1
If Priority = 1 Then 'Yellow
.ListItems.Item(Counter).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(1).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(2).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(3).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(4).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(5).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(6).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(7).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(8).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(9).BackColor = 65535
End If
Next Counter
Exit Function
I have tried this with no success. Thank you all for the help.
Function FormatColors()
Dim Item As ListItem: Dim Counter As Long: Dim Color As String
For Counter = 1 To [Forms]![frm_Schedule_list].ListView1.ListItems.Count
Set Item = [Forms]![frm_Schedule_list].ListView1.ListItems.Item(Counter)
Priority = Item.SubItems(10): With [Forms]![frm_Schedule_list].ListView1
If Priority = 0 Then 'Red
.ListItems.Item(Counter).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(1).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(2).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(3).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(4).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(5).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(6).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(7).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(8).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(9).ForeColor = 255
End If
Next Counter
Exit Function
I would like to know if it is possible to format the background color of the text also maybe something like this
Function FormatColors()
Dim Item As ListItem: Dim Counter As Long: Dim Color As String
For Counter = 1 To [Forms]![frm_Schedule_list].ListView1.ListItems.Count
Set Item = [Forms]![frm_Schedule_list].ListView1.ListItems.Item(Counter)
Priority = Item.SubItems(10): With [Forms]![frm_Schedule_list].ListView1
If Priority = 1 Then 'Yellow
.ListItems.Item(Counter).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(1).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(2).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(3).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(4).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(5).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(6).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(7).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(8).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(9).BackColor = 65535
End If
Next Counter
Exit Function
I have tried this with no success. Thank you all for the help.