Highlight data

R

Ray

I need to highlight data in colours and put the following in the report. It
does not work properly. I need to show a, b or c in the field of Rating in
green colour but now other contents of pa and pb are also appear in green
colour. Can someone tell me how to restrict the only data in exact a, b or
c appeared in green colour.

Thanks,

Ray

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

If Me.[Rating] = "A" Or Me.[Rating] = "B" Or Me.[Rating] = "C" Then

Me![Rating].ForeColor = vbGreen

End If

If Me.[Rating] = "D" Then

Me![Rating].ForeColor = vbYellow

End If

If Me.[Rating] = "E" Then

Me![Rating].ForeColor = vbRed

End If

End Sub
 
D

Duane Hookom

Try the following which should be much easier to maintain.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Select Case Me.Rating
Case "A", "B","C"
Me![Rating].ForeColor = vbGreen
Case "D"
Me![Rating].ForeColor = vbYellow
Case "E"
Me![Rating].ForeColor = vbRed
Case Else
Me.Rating.ForeColor = vbBlack
End Select

End Sub
 
R

Ray

Duane,

Thanks for your useful advice which works out the issue successfully.

Ray

Duane Hookom said:
Try the following which should be much easier to maintain.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Select Case Me.Rating
Case "A", "B","C"
Me![Rating].ForeColor = vbGreen
Case "D"
Me![Rating].ForeColor = vbYellow
Case "E"
Me![Rating].ForeColor = vbRed
Case Else
Me.Rating.ForeColor = vbBlack
End Select

End Sub


--
Duane Hookom
MS Access MVP


Ray said:
I need to highlight data in colours and put the following in the report. It
does not work properly. I need to show a, b or c in the field of Rating in
green colour but now other contents of pa and pb are also appear in green
colour. Can someone tell me how to restrict the only data in exact a, b or
c appeared in green colour.

Thanks,

Ray

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

If Me.[Rating] = "A" Or Me.[Rating] = "B" Or Me.[Rating] = "C" Then

Me![Rating].ForeColor = vbGreen

End If

If Me.[Rating] = "D" Then

Me![Rating].ForeColor = vbYellow

End If

If Me.[Rating] = "E" Then

Me![Rating].ForeColor = vbRed

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

Top