Learn Microsoft Access Advanced Programming Techniques, Tips and Tricks.

Create your own color palette


We have learned Binary, Octal & Hexadecimal Numbering Systems and learned few simple rules by which we can devise new numbering systems with any Base value, provided the user knows about it and can decipher the new number. 

Last week we have worked with a Form to enter Decimal Numbers and get them converted into Binary as well as to display the RGB Color for that number.

If you would like to learn and understand Binary, Octal, and Hexadecimal Numbering Systems then check the following Posts:

  1. Learn Binary Numbering System
  2. Learn Binary Numbering System-2
  3. Octal Numbering System
  4. Hexadecimal Numbering System
  5. Colors 24-Bits And Binary Conversion.

This week, we will work with a Form-based Utility that is more useful to you at the design time of a new Project.  You can create your own 24-bit custom colors visually and save up to 15 colors in a Color Palette on the Form. You can pick any of these colors and apply them to Form background or on other Control's Foreground, Background, or Border Color Properties at design time.

An image of the Employees Form in Design View with the Form's Header Section Property Sheet along with the Color Palette Form is given below for reference:

The Color Palette Usage

New custom color is created on the color palette Form (see the big rectangle) and applied on the Employees Form Header Section Background, by setting the color value in the Back Color Property.

Click on the image to enlarge it.  The Employees Form is in Design View, its Header Section is in the selected state and its Property Sheet with the Back Color Property is visible.  When you click on one of the grids of 15 Color Boxes (these you can create yourself and save it in each box of the color palette, over-writing the existing ones) will display its corresponding color number in the Text Box above the Color Palette with RGB Color label.  You can copy (Ctrl+C) and Paste (Ctrl+V) into the Property Sheet for Value: Back Color, ForeColor, or Border Color, as the case may be, to set the Color of Form Background or Control Colors.

If you are using MS-Access2007 the Color Values in the above Properties will be shown in Hexadecimal Form with the hash symbol like #4E61BC.  But you can paste the Decimal Color Value there and it will automatically convert into Hexadecimal form.  Since, we have learned Hexadecimal Numbering System I want to draw your attention to a small problem in Microsoft Access2007.

A Test Run.

Let us take a sample Color Number in Decimal: 12345678 for the Form Header or Detail Section Background and paste it (or type it) into the Property Sheet and press Enter key. It will be converted into Hexadecimal Number like #4E61BC and the Form Background will be filled with a Dark Blue Color.  Take note of the first two digits and last two digits of Hexadecimal Number shown in blue and red colors.

  1. Now, open the VBA Editing Window (Alt+F11) and display the Debug window (Ctrl+G)

  2. Type ? HEX(12345678) and press Enter key to convert the Decimal Number 12345678 into Hexadecimal Number. The Question mark is the Print Command.

  3. The result will be BC614E and if you paste this value into the Property Sheet as #BC614E it will be accepted as it is and the color displayed will be Dark Red Color instead of Dark Blue.  Compare this number with the earlier number shown in blue and red colors.  MS-Access2007 converts the Color Decimal Number into Hexadecimal form and switches the right-most two Hexadecimal digits with the left-most two digits because it handles the color values (Red and Blue positions) differently.

  4. Suppose you have a Color Value in Hexadecimal form like 614E (24910 decimal) while pasting the value into the Property sheet you must change it to #4E6100 to get the Color equal to the decimal value 24910.  The color number is always expressed in 6 digit hexadecimal number.

  5. The safest method is to Paste the decimal value into the Color Property and let MS-Access2007 take care of the conversion part.

Creating New Colors and Saving it in Color Palette.

Now, we will look at the simple trick of designing new Colors (logically you have over 16 Million 24 Bit Colors to work with) and saving them on the Color palette for later use. 

You can download a database with the above Form with the Programs from a link at the bottom of this article so that you can Import this Form into your new Projects, design your own colors and use them on your Forms or Controls.

You can click on the above image to enlarge it to view the controls properly.  Let us examine the controls on the Form.

  1. There are three Scrollbar controls to input the integer values from 0 - 255 for Red, Green, and Blue colors (primary colors) by moving the Scrollbar's slider controls to the right to increase the value, or left to decrease the value, of each color. If you click on the arrow marks on the right/left edges of the scrollbars then the values will increase by 1 on each click or if you click and hold the control then the value will increase/decrease rapidly and the color graph also will change with it.  You can watch the large rectangle at the bottom right of how the new color is formed by changing the colors with the Red, Green, and Blue Scrollbars.

  2. The Bar Graph at the right of the scrollbars gives a visual indication of the variation of color values, which mixes together to form the new color, and the decimal values appear in the TextBoxes at the left, with the labels Red, Green, and Blue.

  3. The big rectangle label control, at the bottom right of the Form, displays the new color created by setting the values in the scrollbar control.

  4. The Text Box with the Label RGB Color displays the RGB Color Number.

  5. You can highlight the number in the RGB Color Text Box and Copy (Ctrl+C) the Number and Paste (Ctrl+V) it in the Form's/Control's Back Color, ForeColor, or Border Color Property to set the Color there.

  6. If you would like to preserve this newly created color then you can Click on the big rectangle, to pick the Color from there, then click on one of the 15 color boxes shown at the left to store that color there for later use.

  7. If you want to pick a color from one of the saved colors then click on it.  The selected color number will appear in the RGB Color Text Box above.  You can Copy and Paste it in the Color Property of the Form or Control.


  1. You have the RGB Color Number, but you want to modify it to your liking then Copy and Paste that color decimal number into the RGB Color Text Box (or type it in) and press the Enter Key.  The color will appear in the big rectangle and the Red, Green, and Blue Text Boxes will display their corresponding color values. The Bar Chart will give you a visual clue of each color at a glance.  You may then move the slider of the Scrollbar Controls to modify the color.

  2. If you are using MS-Access2007 then you must convert the Hexadecimal Number into Decimal Number by typing? &hXXxxXX in the Debug Window, where xX stands for Hexadecimal digits. Don't forget to interchange the rightmost two digits with the leftmost two digits of the six-digit hexadecimal number.  You will get the result in Decimal Number form and then you can copy it into the RGB Color Text Box to modify.

  3. You can directly enter integer values (Ranging from 0 to 255) in Red, Green, and Blue TextBoxes are given at the left of the Scrollbar Controls to create a new color.

Technorati Tags:

Download the Demo Database.

Download Demo RGBColor.zip


No comments:

Post a Comment

Comments subject to moderation before publishing.



MSA GURU : Access Tips & Tricks App

  • Download Android App 'MSA Guru' Version of LEARN MS-ACCESS TIPS AND TRICKS from Google Play Store.

Want to Post Free Ads on the Web



Subscribe in a reader
Your email address:

Delivered by FeedBurner


Popular Posts

Blog Archive

Powered by Blogger.


Forms Functions How Tos MS-Access Security Reports msaccess forms Animations msaccess animation Utilities msaccess controls Access and Internet MS-Access Scurity MS-Access and Internet Class Module External Links Queries Array msaccess reports Accesstips WithEvents msaccess tips Downloads Objects Menus and Toolbars Collection Object MsaccessLinks Process Controls Art Work Property msaccess How Tos Combo Boxes Dictionary Object Graph Charts Query VBA msaccessQuery Calculation Event List Boxes TreeView Control Command Buttons Controls Data Emails and Alerts Form ImageList Control Custom Functions Custom Wizards DOS Commands Data Type Key Object Reference ms-access functions msaccess functions msaccess graphs msaccess reporttricks Command Button ListView Control Report msaccess menus msaccessprocess security advanced Access Security Add Auto-Number Field Type Form Instances ImageList Item Macros Menus Nodes RaiseEvent Recordset Top Values Variables Wrapper Classes msaccess email progressmeter Access2007 Copy Excel Export Expression Fields Join Methods Microsoft Numbering System Records Security Split SubForm Table Tables Time Difference Utility WScript Workgroup database function msaccess wizards tutorial Access Emails and Alerts Access Fields Access How Tos Access Mail Merge Access2003 Accounting Year Action Animation Attachment Binary Numbers Bookmarks Budgeting ChDir Color Palette Common Controls Conditional Formatting Data Filtering Database Records Defining Pages Desktop Shortcuts Diagram Disk Dynamic Lookup Error Handler External Filter Formatting Groups Hexadecimal Numbers Import Labels List Logo Macro Mail Merge Main Form Memo Message Box Monitoring Octal Numbers Operating System Paste Primary-Key Product Rank Reading Remove Rich Text Sequence SetFocus Summary Tab-Page Union Query User Users Water-Mark Word automatically commands hyperlinks iSeries Date iif ms-access msaccess msaccess alerts pdf files reference restore switch text toolbar updating upload vba code