Solved Getting Color Theme Color Numbers (1 Viewer)

DalynSoft

New member
Local time
Tomorrow, 06:49
Joined
May 23, 2023
Messages
28
I have a button that has it's Back Color property set to Accent 1. When it is clicked I would like the Back Color to be changed to Accent 2.

How do I find out the value of the Accent 2 color so I can apply it to the button? I don't just want to find out and hardcode the current color number because the color in Accent 2 may change. I need the number at the time the button is clicked.
 

isladogs

MVP / VIP
Local time
Today, 22:19
Joined
Jan 14, 2017
Messages
18,233
Theme colours such as Accent1/Accent2 etc depend on the theme used.
If you want to control colours in code its easiest to use standard colours instead.
Alternatively, consider using the theme management tools available at https://www.thememydatabase.co.uk/
 

DalynSoft

New member
Local time
Tomorrow, 06:49
Joined
May 23, 2023
Messages
28
some Constant colors can be found in the discussion here:
[Solved]-Color constants in Access 2007-VBA Excel (appsloveworld.com)
color themes - decimal equivelant documented? (microsoft.com)

or you can manually create a table that will hold all Constants then just create a function that
will lookup the "text equivalent" of a color and show the long value.
Thanks. I tried the negative numbers but they didn't seem to work. However one poster in the thread suggested having hidden controls with the colors as backgrounds and setting the buttons to the appropriate value. EG

Me!cmdTabWall.BackColor = Me!cmdAccent1.BackColor
Me!cmdTabPort.BackColor = Me!cmdAccent2.BackColor

This worked so I am a happy coder :)
 

DalynSoft

New member
Local time
Tomorrow, 06:49
Joined
May 23, 2023
Messages
28
Theme colours such as Accent1/Accent2 etc depend on the theme used.
If you want to control colours in code its easiest to use standard colours instead.
Alternatively, consider using the theme management tools available at https://www.thememydatabase.co.uk/
Thanks Colin,

I wanted the colors to match whatever the theme colors were rather than hard coding specific colors.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 05:19
Joined
May 7, 2009
Messages
19,245
it does work for me? open form Form1 and click the button.
 

Attachments

  • FormColors.accdb
    608 KB · Views: 55

DalynSoft

New member
Local time
Tomorrow, 06:49
Joined
May 23, 2023
Messages
28
it does work for me? open form Form1 and click the button.
Thanks for the effort. I tested your example. I am not sure which color theme it was using but when I selected a color theme I have designed the colors were not changing to the new theme colors. I have attached an updated copy of your sample. It has 4 buttons that have their backgrounds as Accent 1 to 4 (Color theme LandVision). Clicking on the button should change the form background to the colour of the button. Changing the Color theme to a different one doesn't change the colors that the background changes to when each of the buttons are clicked (from pale blue (accent 1) to light blue (accent 4)). I am guessing that the system numbers are using a specific theme to work out the colors and not the theme that has been selected for the database.
 

Attachments

  • FormColors2.accdb
    396 KB · Views: 53

Users who are viewing this thread

Top Bottom