Display different colors on the same text box?

  • Thread starter Thread starter Megaton
  • Start date Start date
M

Megaton

This may sound crazy. If I want to display red for negative numbers and
yellow for positive numbers on the same text box on a report, is it possible?

Thanks
 
Megaton,
Use the OnFormat event for the report section where your control is
located.
Let's say it's in the Detail section, and the control is named Balance.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Balance < 0 Then
Me.Balance.Forecolor = QBColor(12) 'lt red
ElseIf Balance = 0 Then
Me.Balance.Forecolor = QBColor(0) 'black
ElseIf Balance > 0 Then
Me.Balance.Forecolor = QBColor(14) 'lt yellow
End if
End Sub

You didn't indicate what color 0 was, so I included it...
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
This may sound crazy. If I want to display red for negative numbers and
yellow for positive numbers on the same text box on a report, is it possible?

Thanks

Set the control's Format property to:
# [Yellow];-# [Red]; 0 [Blue]

Change [Blue] to whatever color you wish 0 values to display in.
 
Brilliant! Thanks a lot.

Al Campagna said:
Megaton,
Use the OnFormat event for the report section where your control is
located.
Let's say it's in the Detail section, and the control is named Balance.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Balance < 0 Then
Me.Balance.Forecolor = QBColor(12) 'lt red
ElseIf Balance = 0 Then
Me.Balance.Forecolor = QBColor(0) 'black
ElseIf Balance > 0 Then
Me.Balance.Forecolor = QBColor(14) 'lt yellow
End if
End Sub

You didn't indicate what color 0 was, so I included it...
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."





.
 
This works too, although it indent numbers a bit.
Thanks a lot

fredg said:
This may sound crazy. If I want to display red for negative numbers and
yellow for positive numbers on the same text box on a report, is it possible?

Thanks

Set the control's Format property to:
# [Yellow];-# [Red]; 0 [Blue]

Change [Blue] to whatever color you wish 0 values to display in.


--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
.
 
Back
Top