• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 329
  • Last Modified:

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"??????
0
Karen Schaefer
Asked:
Karen Schaefer
  • 7
  • 4
  • 3
  • +1
2 Solutions
 
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
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 MVP, Access and Data Platform)Commented:
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 SchaeferAuthor 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 MVP, Access and Data Platform)Commented:
Using the Windows Calculator ... you can see that ... ironically

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

3059773

!
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Here we go !!

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

Finally !!!

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

mx
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
"i would like to specify the actual color value - what is the proper syntax?"

Me.lblSigned.BackColor = Val("&H" + "2EB03D")
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Me.lblSigned.BackColor = Val("&H" + "InsertYourHexValueHere")
0
 
Karen SchaeferAuthor Commented:
Ok found a Hex to RGB converted and that did the trick.
0
 
Karen SchaeferAuthor 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 MVP, Access and Data Platform)Commented:
:-)
"And you can even simply write it as:"
Well sure. I wrote it the other way for clarity ...
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 7
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now