Karen Schaefer
asked on
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"??????
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"??????
What do you mean the "actual color value"? If you want to set it to vbGreen, then you use that:
Me.lblSigned.BackColor = vbGreen
Me.lblSigned.BackColor = vbGreen
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
mx
In addition, you would use vbBlack instead of lngBlack. Valid color constants are
vbBlack
vbRed
vbGreen
vbYellow
vbBlue
vbMagenta
vbCyan
vbWhite
vbBlack
vbRed
vbGreen
vbYellow
vbBlue
vbMagenta
vbCyan
vbWhite
Of course, if you want some other of the millions of colors ....
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
Ron
ASKER
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.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here we go !!
Val("&H" + "2EB03D") = 3059773
Finally !!!
Me.lblSigned.BackColor = Val("&H" + "2EB03D")
mx
Val("&H" + "2EB03D") = 3059773
Finally !!!
Me.lblSigned.BackColor = Val("&H" + "2EB03D")
mx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Me.lblSigned.BackColor = Val("&H" + "InsertYourHexValueHere")
ASKER
Ok found a Hex to RGB converted and that did the trick.
ASKER
thanks for the input.
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)
:-)
"And you can even simply write it as:"
Well sure. I wrote it the other way for clarity ...
"And you can even simply write it as:"
Well sure. I wrote it the other way for clarity ...
Ron