Display different colors on the same text box?

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
 
A

Al Campagna

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."
 
F

fredg

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.
 
M

Megaton

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."





.
 
M

Megaton

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
.
 

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