Conditionally format Yes/No field in Access 2010

Posted on 2012-08-27
Last Modified: 2012-08-28
hi All
I had thought this would be straightforward enough but when I went to conditionally format a field on a form as Green for Yes and Red for no - it turns out that Conditional formatting is not available.  The idea is that when the user ticks a box it goes green and when it's unticked, its red...
Any suggestions? As always thank you
Question by:agwalsh
    LVL 13

    Expert Comment

    The checkbox itself has no color, but you can modify the forecolor or back color of the associated label.

    Private Sub Check1_AfterUpdate()
      Label2.BackColor = IIf(Check1.Checked, acColorIndexGreen, acColorIndexRed)
    End Sub

    The other option is to put a box behind both the check and the label, and color its backcolor, which may look more intuitive to the user.
    LVL 39

    Expert Comment

    You can use combination of Yes/No field and simple field. Look at example
    LVL 30

    Expert Comment

    MrBullwinkle's comment is what you need..
    You may use vbGreen and vbRed for colors.

    Other thing I noticed is that color will not change unless I manually set the baccolor first. I selected automatic for baccolor and it displayed the same value Background 1. Could be my settings.

    Author Comment

    @als315 - Thanks for that - I see how it works. I've tried that with the attached form mFrmLocations (which has a subform that I want to put the boxes into and is in datasheet view - rather than the continuous forms you have)  and I've tried to set a background text box to green when January is ticked - but it doesn't seem to work. Thanks!
    LVL 39

    Accepted Solution

    You have very limited formatting abilities in datasheet view. Try this sample with continuous form.

    Author Closing Comment

    Exactly what I wanted - elegant and easy solution. YUM!

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
    The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now