Color Rating Fields

M

MyMel

Hi,

I am trying to color rate fields on status level (ex.HIGH/RED,
Medium/YELLOW and Low/GREEN). I have created code that does that but
when the choice is made the back color is changed for all the records
for that specific field. I want it to specific only for that one field
for that one invoice.

I would appreciate any suggestions, please. Thank you

My Code:
Private Sub Status_AfterUpdate()

Dim Rating As String
Dim Red As Long, Yellow As Long, Green As Long

If Not IsNull(Me!Status) Then
Rating = Me!Status
Else
Exit Sub
End If

Red = RGB(255, 0, 0)
Green = RGB(0, 255, 0)
Yellow = RGB(255, 255, 0)
White = RGB(255, 255, 255)

If Rating = "High" Then
Me!Status.BackColor = Red
ElseIf Rating = "Medium" Then
Me!Status.BackColor = Yellow
ElseIf Rating = "Low" Then
Me!Status.BackColor = Green
Else
Me!Status.BackColor = White
End If
End Sub
 
O

Ofer Cohen

Instead of using code use the conditional formating to do that for you.
Open the form in des

Open the form in design view,
select the field,
and from the menu bar select: Format > Conditional formating.

You can select the value and the way you want this field to be displayed for
that value

[Rating] = "Medium"
 
M

MyMel

Thanks for the information. It works great now.

Ofer Cohen said:
Instead of using code use the conditional formating to do that for you.
Open the form in des

Open the form in design view,
select the field,
and from the menu bar select: Format > Conditional formating.

You can select the value and the way you want this field to be displayed for
that value

[Rating] = "Medium"

--
Good Luck
BS"D


MyMel said:
Hi,

I am trying to color rate fields on status level (ex.HIGH/RED,
Medium/YELLOW and Low/GREEN). I have created code that does that but
when the choice is made the back color is changed for all the records
for that specific field. I want it to specific only for that one field
for that one invoice.

I would appreciate any suggestions, please. Thank you

My Code:
Private Sub Status_AfterUpdate()

Dim Rating As String
Dim Red As Long, Yellow As Long, Green As Long

If Not IsNull(Me!Status) Then
Rating = Me!Status
Else
Exit Sub
End If

Red = RGB(255, 0, 0)
Green = RGB(0, 255, 0)
Yellow = RGB(255, 255, 0)
White = RGB(255, 255, 255)

If Rating = "High" Then
Me!Status.BackColor = Red
ElseIf Rating = "Medium" Then
Me!Status.BackColor = Yellow
ElseIf Rating = "Low" Then
Me!Status.BackColor = Green
Else
Me!Status.BackColor = White
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top