How-to: Microsoft Access Colors

The color of many objects (forms, buttons,text etc) in Microsoft access can be set, either manually or using VBA. The exact colour is specified as either a Long number or (in recent versions) a Hex color code.

You can convert any 6 digit Hex color code into a long integer below:

  Hex Color
Long Color code
 

Typically these colours are applied to the .backcolor, .forecolor and .hover properties

When storing a color code in a VBA variable use a 32-bit Long (max=2,147,483,647), not the default Integer (max=65535).
It is also possible to specify a hex constant like &FF005F& the extra & on the end denotes a 32 bit Long.

Converting hex colors to long can also be done with the RGB function.

In Access 2010, it was possible to set colors based on the users current desktop theme, with a set of constants System Button Face, System Button Shadow etc. In Windows 10 the theme system has changed and these values can no longer be edited in the Control Panel making that functionality redundant.

Examples

Me!txtAddress.BackColor = &FF005F&

Me!txtPostcode.ForeColor = 16712640

“Speed kills colour... the gyroscope, when turning at full speed, shows up gray” ~ Paul Morand

Related

Access Form References - Reference controls on subforms.
Average (mix) colours - EMW3
List of Access color codes - Endprod.com


 
Copyright © 1999-2024 SS64.com
Some rights reserved