Color constants in Access 2007
Asked Answered
S

4

5

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?

Shikoku answered 5/1, 2011 at 19:7 Comment(0)
C
1

They may come from Windows system settings and not correspond to the same RGB value on every computer.

After finding this

You can also see in the Back Color property (or, for that matter, any color property) a list of 20 additional options. These include Alternate Row, Background Form, Background Light Header, Background Dark Header, Borders/Gridlines, Text Black, Text Description, Text Light, Text Dark, Highlight, and Access Theme 1, Access Theme 2, and so on, up to Access Theme 10. These are shades of the color scheme you chose in Access Options-shades of blue for the Blue or Silver theme, and shades of gray and black for the Black theme, and with a shade of orange in all themes for Highlight.

here

I'm now thinking it's local to Access. It may be something you can't do with a single RGB value.

Clef answered 5/1, 2011 at 19:51 Comment(3)
That's what I thought, but I don't see them in the System constants anywhere I've looked so far....Shikoku
I think @Clef means the colour that you have chosen for light and dark text under appearance: "Windows Standard", "Windows Aero", etc.Footlights
Those are exactly the colors I want to use, so that they track along with user Theme selection--but I want to do it dynamically, in code, so that I can use the header colors to indicate whether or not the user can modify items on the form (without making the individual items grey & illegible). Thanks for finding the BOL entry--it doesn't fully answer the question, since it doesn't tell me how to use them at run time, but it's more than I'd found so far.Shikoku
C
6

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=accessdev

Public 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.

Crocked answered 22/5, 2015 at 12:18 Comment(0)
S
2

I found the answer, the (sort of) hard way. I already have forms with the colors I want set up at design time, so I set breakpoints during their load, and used Debug.Print to find their values. I'll Edit this answer with the values after I play around a bit and make sure I'm not mixing up which is which.

In the meantime, I'm going to Accept Beth's answer, since it got me thinking in the direction that led to the solution.

Edit

Here are the values for the four that I asked about originally, in context:

Public Sub SetHeader(frm As Form)
On Error GoTo Error_Handler

'Access-specific Theme colors
Const TextLight     As Long = -2147483616
Const TextDark      As Long = -2147483615
Const BackLight     As Long = -2147483612
Const BackDark      As Long = -2147483611


    With frm
        If gblnAuthorized Then
            .FormHeader.BackColor = BackLight
            !Auto_Title0.ForeColor = TextDark
        Else
            .FormHeader.BackColor = BackDark
            !Auto_Title0.ForeColor = TextLight
        End If
    End With

Exit_Procedure:
    Exit Sub

Error_Handler:
    DisplayUnexpectedError Err.Number, Err.Description
    Resume Exit_Procedure
    Resume
End Sub

Edit 2

Just by accident, I found an easier way to find the values for these. Go into the VB Editor and open the form's code. Select the control in the drop down at the top of the Propeties window and read the BackColor (or whatever) from there--it's in the same decimal format I used in the code above, rather than the name used in the Acces design environment. Edit 3 The form has to be open in Design or Layout view in the main Access environment for this to work.

Shikoku answered 5/1, 2011 at 22:37 Comment(2)
You might consider creating an ENUM so you could then use the ENUM in defining parameters for functions/subs.Smoko
Good point about Enums. Current usage is that this Sub lives in a module of global procedures, and gets called from Form_Load of (almost) every form, along with a Sub that locks or unlocks the data entry controls. I don't anticipate using these values anywhere else, but it's better to be prepared.Shikoku
C
1

They may come from Windows system settings and not correspond to the same RGB value on every computer.

After finding this

You can also see in the Back Color property (or, for that matter, any color property) a list of 20 additional options. These include Alternate Row, Background Form, Background Light Header, Background Dark Header, Borders/Gridlines, Text Black, Text Description, Text Light, Text Dark, Highlight, and Access Theme 1, Access Theme 2, and so on, up to Access Theme 10. These are shades of the color scheme you chose in Access Options-shades of blue for the Blue or Silver theme, and shades of gray and black for the Black theme, and with a shade of orange in all themes for Highlight.

here

I'm now thinking it's local to Access. It may be something you can't do with a single RGB value.

Clef answered 5/1, 2011 at 19:51 Comment(3)
That's what I thought, but I don't see them in the System constants anywhere I've looked so far....Shikoku
I think @Clef means the colour that you have chosen for light and dark text under appearance: "Windows Standard", "Windows Aero", etc.Footlights
Those are exactly the colors I want to use, so that they track along with user Theme selection--but I want to do it dynamically, in code, so that I can use the header colors to indicate whether or not the user can modify items on the form (without making the individual items grey & illegible). Thanks for finding the BOL entry--it doesn't fully answer the question, since it doesn't tell me how to use them at run time, but it's more than I'd found so far.Shikoku
P
0
VBA Constant                Description

vbScrollBars                Scrollbar color
vbDesktop                   Desktop color
vbActiveTitleBar            Color of the title bar for the active window
vbInactiveTitleBar          Color of the title bar for the inactive window
vbMenuBar                   Menu background color
vbWindowBackground          Window background color
vbWindowFrame               Window frame color
vbMenuText                  Color of text on menus
vbWindowText                Color of text in windows
vbTitleBarText              Color of text in caption, size box, and scroll arrow
vbActiveBorder              Border color of active window
vbInactiveBorder            Border color of inactive window
vbApplicationWorkspace      Background color of multiple document interface applications
vbHighlight                 Background color of items selected in a control
vbHighlightText             Text color of items selected in a control
vbButtonFace                Color of shading on the face of command buttons
vbButtonShadow              Color of shading on the edge of command buttons
vbGrayText                  Grayed (disabled) text
vbButtonText                Text color on push buttons
vbInactiveCaptionText       Color of text in an inactive caption
vb3DHighlight               Highlight color for 3-D display elements
vb3DDKShadow                Darkest shadow color for 3-D display elements
vb3DLight                   Second lightest 3-D color after vb3DHighlight
vbInfoText                  Color of text in ToolTips
vbInfoBackground            Background color of ToolTips
Participate answered 26/6, 2016 at 0:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.