The MS Access 2007 Form Design view property sheet exposes some color options that I can't seem to find constants for in order to use them in code. Specifically: Text Dark
, Text Light
, Background Dark Header
and Background Light Header
.
Do predefined constants for these exist? I don't seem them in the Object Browser or the Help. Failing that, does anyone know their RGB hex values offhand?
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.
After creating your textbox right click to access its settings. Click on the blank box next to the Background Color option. Use the color scale to choose your color, or enter the appropriate hexadecimal code. Use the slider, or input a percentage to set the background opacity.
This isn't very well documented at all by Microsoft, so I'll put in a late answer for everyone else who's searching Google for Access Color Constant "Background Light Header".
The best information I've seen is Chris Ward's answer to 'Access system color constants' on the MSDN AccessDev forum, posted on January 1st 2013.
I've reformatted that information into an enumeration:
' Access system color constants, documented by Chris Ward on MSDN Forums, 01-Jan-2013 ' https://social.msdn.microsoft.com/Forums/en-US/ccf8b3b7-fa6b-4d05-9883-44b3642e6688/color-themes-decimal-equivelant-documented?forum=accessdevPublic Enum SysColors acColor_Access_Theme_8 = -2147483600 ' Access Theme 8 acColor_Access_Theme_7 = -2147483601 ' Access Theme 7 acColor_Access_Theme_6 = -2147483602 ' Access Theme 6 acColor_Access_Theme_5 = -2147483603 ' Access Theme 5 acColor_Access_Theme_4 = -2147483604 ' Access Theme 4 acColor_Access_Theme_3 = -2147483605 ' Access Theme 3 acColor_Access_Theme_2 = -2147483606 ' Access Theme 2 acColor_Access_Theme_1 = -2147483607 ' Access Theme 1 acColor_Highlight = -2147483608 ' Highlight acColor_Borders_Gridlines = -2147483609 ' Borders/Gridlines acColor_Altenate_Row = -2147483610 ' Altenate Row acColor_Background_Dark_Header = -2147483611 ' Background Dark Header acColor_Background_Light_Header = -2147483612 ' Background Light Header acColor_Background_Form = -2147483613 ' Background Form acColor_Text_Description = -2147483614 ' Text Description acColor_Text_Dark = -2147483615 ' Text Dark acColor_Text_Light = -2147483616 ' Text Light acColor_Text_Black = -2147483617 ' Text Black acColor_System_Menu_Bar = -2147483618 ' System Menu Bar acColor_System_Menu_Highlight = -2147483619 ' System Menu Highlight acColor_System_Gradient_Inactive_Caption = -2147483620 ' System Gradient Inactive Caption acColor_System_Gradient_Active_Caption = -2147483621 ' System Gradient Active Caption acColor_System_Static_Text = -2147483622 ' System Static Text acColor_System_Static = -2147483623 ' System Static acColor_System_Tooltip_Background = -2147483624 ' System Tooltip Background acColor_System_Tooltip_Text = -2147483625 ' System Tooltip Text acColor_System_3D_Light = -2147483626 ' System 3D Light acColor_System_3D_Shadow = -2147483627 ' System 3D Shadow acColor_System_3D_Highlight = -2147483628 ' System 3D Highlight acColor_System_Inactive_Caption_Light = -2147483629 ' System Inactive Caption Light acColor_System_Button_Text = -2147483630 ' System Button Text acColor_System_Alternate_Row = -2147483631 ' System Alternate Row acColor_System_Button_Shadow = -2147483632 ' System Button Shadow acColor_System_Button_Face = -2147483633 ' System Button Face acColor_System_Highlight_Text = -2147483634 ' System Highlight Text acColor_System_Highlight = -2147483635 ' System Highlight acColor_System_Application_Background = -2147483636 ' System Application Background acColor_System_Inactive_Border = -2147483637 ' System Inactive Border acColor_System_Active_Border = -2147483638 ' System Active Border acColor_System_Title_Bar_Text = -2147483639 ' System Title Bar Text acColor_System_Window_Text = -2147483640 ' System Window Text acColor_System_Menu_Text = -2147483641 ' System Menu Text acColor_System_Window_Frame = -2147483642 ' System Window Frame acColor_System_Window = -2147483643 ' System Window acColor_System_Menu_Background = -2147483644 ' System Menu Background acColor_System_Inactive_Title_Bar = -2147483645 ' System Inactive Title Bar acColor_System_Active_Title_Bar = -2147483646 ' System Active Title Bar acColor_System_Desktop = -2147483647 ' System Desktop acColor_System_Scrollbar = -2147483648# ' System Scrollbar End Enum
Note that these aren't numerically-encoded RGB colors: they are addresses to system constants or variables pointing to RGB color definitions which will change if a custom system or application color theme is selected.
This is actually a good thing, as users requiring accessibility settings - high contrast being the most common example - won't be nailed down by your hardcoded color specifications.
You might ask me how to enumerate the lighter and darker tints - 'Text 1, Lighter 50%' and so on - but they aren't actually numeric constants: the 'Lighter' and 'Darker' part of a color descriptor are actually calls to the control's .BackTint
and .BackShade
methods (for background colors), and the font's Font.TextColor.TintAndShade
property (for foreground colors), and you can call those methods from VBA too.
However, I recommend that you open up the help page when you code it up, because the methods for backgrounds and fonts work in slightly different ways, and that inconsistency will catch you out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With