Red if no, green if yes

tomas_s

Registered User.
Local time
Today, 04:30
Joined
Mar 12, 2013
Messages
25
my database has a field which says if the items on it are active or not. And I could use some help, to make it so that if the answer is "no", the letters will be red, and "yes" the letters will be green.

It takes the info directly from a table. Any ideas how I can make it do that? is it the macro or?
 
Simplest is Conditional Formatting, on the ribbon.
 
oh cool. that works great. :)
Found it. Thanx.
 
doesn't seem to work.

I can't pick "field value is" and "equal to" and then write "yes", and change the formatting. it has to be a number right?

Should I use "expression is"?
Im lost..:(
 
You can use Yes in the Conditional formatting if you want.. What is the trouble you are having?
 
You wouldn't want the quotes if it's a yes/no field.
 
just doesn't work.

if as I open conditioning formating for the object (yes/no).

I pick "field value is" and "equal to" and then write "yes", and change the formatting (so it gets green).

But when I go back to the form, view mode, no changes. still the original black color. Very annoying. I blame myself, something I must have missed.
 
No I can't post a photo, rather new to this forum.

But I just tried to change the conditioning format of another field, and it worked just fine (!) So I know that I am doing it right. There is just something about the "yes/no" field that doesn't work.
 
No I can't post a photo, rather new to this forum.
Thought I gave the link on how to add pictures even if you are a New person on this Forum.. But anyway..
But I just tried to change the conditioning format of another field, and it worked just fine (!) So I know that I am doing it right. There is just something about the "yes/no" field that doesn't work.
Is the "yes/no" CONTROL a CheckBox? If the answer is yes.. Try a -1/True instead of a Yes...
 
its not a check box... its just a "short text" column.
 
I haven't figured it out. But I have tried to change the conditioning format on several fields, and it works just as it should. The only difference between these and the "active" field, is that I added the field to the original table, and then added it to the form through "add existing fields".

I think I need to update the form or something.
 
I have tried my best to recreate the problem, but it does not seem to work.. So I am not sure.. Sorry I could not be of great help here..
 
no listen, I really am grateful for the help.. :)

I will figure it out. At least I know now how to do it, once I get it working. :)
 
Are you using a FORM view or a DATASHEET view?

I have used conditional formatting when using datasheet view. When using form view, I either change the color of the text (forecolor) in the field and/or change the color of the border (bordercolor) to the field.
 
im using a formview. And I have tried other fields, and it works to use conditional formatting on other fields, except for this misserable field that in the original table works the same as the other fields (or columns).
its called ACTIVE and it the type is "short text". And it says either yes or no. But the color won't change. it is always black.

I have even tried to make a new form from scratch. And the problem remains.
I want to say: STUPID ACCESS
but the truth is that the error is probably my doing somehow. It usually is...
 
Tomas, is it possible if you could upload a dummy version of the troubling form/table that we may look at?
 
Without knowing too much about your structure, below is a code outline. This suggestion applies when using FORM view.

Code:
If SomeValue = X then Me.Field123.Forecolor = GreenColor ELSE  me.Field123.Forecolor = RedColor

Below is a code sample for changing the border color of a text field when it receives and losses focus as a further illustration. When the textbox has the focus, it has a red border. When it losses the focus, the border is made transparent and changed to the color of the form's background color so that it is invisible. The code below can be modified to meet your needs.

Code:
Private Sub DCMnum01_GotFocus()
    Call Enter_TextBox(Me.Name, Me.ActiveControl.Name)  
End Sub

Code:
Public Sub Enter_TextBox(strFormName As String, strControlName As String)
    Forms(strFormName).Controls(strControlName).Properties("borderstyle") = 1       'Solid Line
    Forms(strFormName).Controls(strControlName).Properties("BorderWidth") = 4
    Forms(strFormName).Controls(strControlName).Properties("bordercolor") = Redclr
End Sub
Code:
Private Sub DCMnum01_LostFocus()
    Call Exit_TextBox(Me.Name, Me.ActiveControl.Name, Me.Detail.BackColor)    
End Sub
Code:
Public Sub Exit_TextBox(strFormName As String, strControlName As String, lonFormBackColor As Long)
    Forms(strFormName).Controls(strControlName).Properties("borderstyle") = 0       'Transparant
    Forms(strFormName).Controls(strControlName).Properties("bordercolor") = lonFormBackColor
End Sub
 
Last edited:
I have finally solved it. Tried making a new database, and the problem remained.

You wanna know what helped?

*drum roll*

instead of having Yes and No, I changed it to "active" and "not active". And it worked. why I don't know. Perhaps access has made a internal rule to not allow conditioning formatting on values like yes or no.

OR...

I also changed the column from "Active" to "Status". maybe that helped. Either way, I solved it.
 
out of interest, did you have a text field with values yes and no, or did you have boolean field. that may have been the issue.

if it was boolean, rather than yes and no try TRUE and FALSE

a boolean is a better choice then having text saying "ACTIVE" etc.
 

Users who are viewing this thread

Back
Top Bottom