Conditional formatting - non-std background colors?

Posted on 2006-04-20
Last Modified: 2012-06-21
I am using conditional formatting in a datasheet.  I want one of the conditions to produce a backcolor that is not among the std colors in MSAccess.

Is it possible to implement Conditional Formatting in code and select custom color codes?

Any sample code to sahre?

Question by:markp99
    LVL 11

    Expert Comment

    After selecting the color in design view of your form, click "Define Custom Color". This offers you a complete pallette of the spectrum and you can create ANY color you want. I don't believe you can import a custom color.

    Author Comment


    I can see "define custom color" while in design view.  I have created the shade I desire and added it to the custom color section of the color pallet.

    However, when I select Conditional Formatting for a field on a form, I still only see the standard set of 40 colors.  My "custom color" is not visible in the pallet.

    Am I doing something wrong, or maybe I misunderstood your reply?



    Author Comment

    Found a solution:

    1. Open the form in design view.

    2. Select the field in question, choose Conditional Formatting (CF) from the
    Format menu. Set the condition you want, and click any std color in the
    pallet - say, red. Close the CF dialog.

    3. Press Ctrl+G to open the Immediate Window.

    4. Type this into the Immediate window:    
        ? Forms![FormName]![FieldName].FormatConditions(0).BackColor
    Displays the current backcolor setting for condition 0 (first condition)
    Red = 255

    5. Now that you know the expression is working, you can assign the color you
    want by entering:
        Forms![FormName]![FieldName].FormatConditions(0).BackColor = 65000

    6. Save the form. In future, the CF on this text box will use the NEW
    background color.

    7. Repeat for other attributes and conidtions.

    This question may be closed.

    LVL 58

    Expert Comment


    You are right, there is no other way. In addition to the above, you can use, as for all color properties:

        .....BackColor = RGB(192,192,192)   ' three color components
        .....BackColor = &HFFFF00&            ' color as hex value
        .....BackColor = vbActiveTitleBar       ' system color constants (desktop theme)
        .....ForeColor = vbTitleBarText         ' logically ;)

    This being said, it's of course a case for {http:/help.jsp#hi70} -- thanks for the detailed answer!


    Accepted Solution

    PAQed with points refunded (250)

    Community Support Moderator

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
    In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

    733 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

    20 Experts available now in Live!

    Get 1:1 Help Now