Highlight the background of the text

  • Thread starter Thread starter Ray
  • Start date Start date
R

Ray

I use following event procedure in report but the background colors have no
effect at all but other two formats are ok. Can someone point me out where
I may make a mistake. I am using Access 97.

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

If Me.[1] >= 65 Then
Me![1].BackColor = vbGreen
Me![1].ForeColor = vbBlack
Me![1].FontBold = True


ElseIf Me.[1] >= 50 And Me.[1] <= 64 Then
Me![1].BackColor = vbYellow
Me![1].ForeColor = vbBlack
Me![1].FontBold = True

ElseIf Me.[1] >= 0 And Me.[1] <= 49 Then
Me![1].BackColor = vbRed
Me![1].ForeColor = vbBlack
Me![1].FontBold = True

End If

End Sub



Thanks,

Ray
 
Ray said:
I use following event procedure in report but the background colors have no
effect at all but other two formats are ok. Can someone point me out where
I may make a mistake. I am using Access 97.

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

If Me.[1] >= 65 Then
Me![1].BackColor = vbGreen
Me![1].ForeColor = vbBlack
Me![1].FontBold = True


ElseIf Me.[1] >= 50 And Me.[1] <= 64 Then
Me![1].BackColor = vbYellow
Me![1].ForeColor = vbBlack
Me![1].FontBold = True

ElseIf Me.[1] >= 0 And Me.[1] <= 49 Then
Me![1].BackColor = vbRed
Me![1].ForeColor = vbBlack
Me![1].FontBold = True

End If


You have a text box named 1 ???

Try adding an Else clause with a message box to display the
actual value when it is not in the above ranges??

Since you always set the forecolor to black, you can't tell
if this has any meaning.

Add a few break points and step through the code to see what
code is actually executing.
 
In addition, you might check to make sure that the control's BackStyle is NORMAL
and not TRANSPARENT. If it is transparent, you can change the backcolor all you
want, but you will still see the color of the report section's backcolor.

Marshall said:
I use following event procedure in report but the background colors have no
effect at all but other two formats are ok. Can someone point me out where
I may make a mistake. I am using Access 97.

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

If Me.[1] >= 65 Then
Me![1].BackColor = vbGreen
Me![1].ForeColor = vbBlack
Me![1].FontBold = True


ElseIf Me.[1] >= 50 And Me.[1] <= 64 Then
Me![1].BackColor = vbYellow
Me![1].ForeColor = vbBlack
Me![1].FontBold = True

ElseIf Me.[1] >= 0 And Me.[1] <= 49 Then
Me![1].BackColor = vbRed
Me![1].ForeColor = vbBlack
Me![1].FontBold = True

End If

You have a text box named 1 ???

Try adding an Else clause with a message box to display the
actual value when it is not in the above ranges??

Since you always set the forecolor to black, you can't tell
if this has any meaning.

Add a few break points and step through the code to see what
code is actually executing.
 
John,

Many thanks for your useful advice.

Ray

John Spencer (MVP) said:
In addition, you might check to make sure that the control's BackStyle is NORMAL
and not TRANSPARENT. If it is transparent, you can change the backcolor all you
want, but you will still see the color of the report section's backcolor.

Marshall said:
I use following event procedure in report but the background colors have no
effect at all but other two formats are ok. Can someone point me out where
I may make a mistake. I am using Access 97.

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

If Me.[1] >= 65 Then
Me![1].BackColor = vbGreen
Me![1].ForeColor = vbBlack
Me![1].FontBold = True


ElseIf Me.[1] >= 50 And Me.[1] <= 64 Then
Me![1].BackColor = vbYellow
Me![1].ForeColor = vbBlack
Me![1].FontBold = True

ElseIf Me.[1] >= 0 And Me.[1] <= 49 Then
Me![1].BackColor = vbRed
Me![1].ForeColor = vbBlack
Me![1].FontBold = True

End If

You have a text box named 1 ???

Try adding an Else clause with a message box to display the
actual value when it is not in the above ranges??

Since you always set the forecolor to black, you can't tell
if this has any meaning.

Add a few break points and step through the code to see what
code is actually executing.
 
Marchall,

Thanks for your response and advice on locating the fault.

Ray

Marshall Barton said:
Ray said:
I use following event procedure in report but the background colors have no
effect at all but other two formats are ok. Can someone point me out where
I may make a mistake. I am using Access 97.

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

If Me.[1] >= 65 Then
Me![1].BackColor = vbGreen
Me![1].ForeColor = vbBlack
Me![1].FontBold = True


ElseIf Me.[1] >= 50 And Me.[1] <= 64 Then
Me![1].BackColor = vbYellow
Me![1].ForeColor = vbBlack
Me![1].FontBold = True

ElseIf Me.[1] >= 0 And Me.[1] <= 49 Then
Me![1].BackColor = vbRed
Me![1].ForeColor = vbBlack
Me![1].FontBold = True

End If


You have a text box named 1 ???

Try adding an Else clause with a message box to display the
actual value when it is not in the above ranges??

Since you always set the forecolor to black, you can't tell
if this has any meaning.

Add a few break points and step through the code to see what
code is actually executing.
 
Back
Top