Setting background color to specified value

Me.lblSigned.BackColor = "#2EB03D" 'vbGreen
        Me.lblSigned.ForeColor = lngblack
        Me.lblSigned.Caption = "SIGNED"
        Me.Sub1.Enabled = True

i would like to specify the actual color value - what is the proper syntax?

 Me.lblSigned.BackColor = "#2EB03D"??????
Karen SchaeferBI ANALYSTAsked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Connect With a Mentor Database ArchitectCommented:
"i would like to specify the actual color value - what is the proper syntax?"

Me.lblSigned.BackColor = Val("&H" + "2EB03D")
0
 
IrogSintaCommented:
You need to use the RGB equivalent or the long value used by Access for that color.  In this case you can use either:
Me.lblSigned.BackColor = RGB(46, 176, 61)
Me.lblSigned.BackColor = 3059773

Ron
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
What do you mean the "actual color value"? If you want to set it to vbGreen, then you use that:

Me.lblSigned.BackColor = vbGreen
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
I was trying to do that the other day ... with no luck. BUT ... I have got to believe ... there is a way, since Access now supports the hex format in the property sheet ....

mx
0
 
IrogSintaCommented:
In addition, you would use vbBlack instead of lngBlack. Valid color constants are
vbBlack
vbRed
vbGreen
vbYellow
vbBlue
vbMagenta
vbCyan
vbWhite
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Of course, if you want some other of the millions of colors ....
0
 
IrogSintaCommented:
As I posted earlier, for custom colors, you would use the RGB equivalent or the long value used by Access; however, Mx, I'm inclined to agree with you that there should be a way to use the Hex value instead but I haven't come across a way to do that either.

Ron
0
 
Karen SchaeferBI ANALYSTAuthor Commented:
I know but the color of green is to harsh - so I was hoping to be able to select from the color wheel the specified color - or is there a way to get the RGB equivalent of the specific color value.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Connect With a Mentor Database ArchitectCommented:
Using the Windows Calculator ... you can see that ... ironically

the Decimal value of Hex 2EB03D is ... .... ....

3059773

!
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Here we go !!

Val("&H" + "2EB03D") = 3059773

Finally !!!

Me.lblSigned.BackColor = Val("&H" + "2EB03D")

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Me.lblSigned.BackColor = Val("&H" + "InsertYourHexValueHere")
0
 
Karen SchaeferBI ANALYSTAuthor Commented:
Ok found a Hex to RGB converted and that did the trick.
0
 
Karen SchaeferBI ANALYSTAuthor Commented:
thanks for the input.
0
 
IrogSintaCommented:
That's pretty good, mx. And you can even simply write it as:
Me.lblSigned.BackColor = Val("&h2EB03D")
Incidentally, just for information sake, each 2 characters of the hex color value represents Red, Green, and Blue respectively. So
2E ==>  2 x 16 + 14 = 46   (E is 14 in decimal with A representing 10, B is 11, etc.)
B0 ==> 11 x 16 + 0 = 176   (B is 11)
3D ==>  3 x 16 + 13 = 61   (D is 13)

RGB(46, 176, 61)

Open in new window

0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
:-)
"And you can even simply write it as:"
Well sure. I wrote it the other way for clarity ...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.