Making a output of a text box turn red under certain criteria.

P

PJ

I have the following in a control source for a text box:

=IIf([frmContLiabBorrowerPendingInfoSubform].[Form]![Total:] Is
Null,"$0.00",[frmContLiabBorrowerPendingInfoSubform].[Form]![Total:])


I want the output to be black if at $0.00 and Red if a dollar amount. How
would I code that?

Thanks in advance.
 
K

Ken Snell MVP

Use Conditional Formatting for the textbox to set the desired font color
based on the value in the textbox.
 
J

John W. Vinson

I have the following in a control source for a text box:

=IIf([frmContLiabBorrowerPendingInfoSubform].[Form]![Total:] Is
Null,"$0.00",[frmContLiabBorrowerPendingInfoSubform].[Form]![Total:])


I want the output to be black if at $0.00 and Red if a dollar amount. How
would I code that?

Thanks in advance.

Open the form or report in design view; select the textbox; and choose
Format... Conditional Formatting from the menu.

Do note that you're going the long way about for this. You can instead use

NZ([Total:], 0)

and set the Format property of the textbox to Currency.
 
P

PJ

What do I do if I am working in Access 97?

Ken Snell MVP said:
Use Conditional Formatting for the textbox to set the desired font color
based on the value in the textbox.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


PJ said:
I have the following in a control source for a text box:

=IIf([frmContLiabBorrowerPendingInfoSubform].[Form]![Total:] Is
Null,"$0.00",[frmContLiabBorrowerPendingInfoSubform].[Form]![Total:])


I want the output to be black if at $0.00 and Red if a dollar amount. How
would I code that?

Thanks in advance.
 
K

Ken Snell MVP

You might try using the form's Current event to run code like this:

Private Sub Form_Current()
Select Case Me.NameOfYourTextbox.Value
Case 0
Me.NameOfYourTextbox.ForeColor = vbBlack
Case Else
Me.NameOfYourTextbox.ForeColor = vbRed
End Select
End Sub


You also should run similar code in the AfterUpdate event of any control on
the form where, if you enter / change a value, the value in the above
textbox will possibly change.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



PJ said:
What do I do if I am working in Access 97?

Ken Snell MVP said:
Use Conditional Formatting for the textbox to set the desired font color
based on the value in the textbox.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


PJ said:
I have the following in a control source for a text box:

=IIf([frmContLiabBorrowerPendingInfoSubform].[Form]![Total:] Is
Null,"$0.00",[frmContLiabBorrowerPendingInfoSubform].[Form]![Total:])


I want the output to be black if at $0.00 and Red if a dollar amount.
How
would I code that?

Thanks in advance.
 

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