Solved

Setting background color to specified value

Posted on 2014-02-21
15
319 Views
Last Modified: 2014-02-21
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
Comment
Question by:Karen Schaefer
  • 7
  • 4
  • 3
  • +1
15 Comments
 
LVL 29

Expert Comment

by:IrogSinta
ID: 39878254
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
 
LVL 84
ID: 39878256
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
 
LVL 75
ID: 39878257
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
 
LVL 29

Expert Comment

by:IrogSinta
ID: 39878265
In addition, you would use vbBlack instead of lngBlack. Valid color constants are
vbBlack
vbRed
vbGreen
vbYellow
vbBlue
vbMagenta
vbCyan
vbWhite
0
 
LVL 75
ID: 39878283
Of course, if you want some other of the millions of colors ....
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 39878295
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
 

Author Comment

by:Karen Schaefer
ID: 39878307
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Access MVP)
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 39878310
Using the Windows Calculator ... you can see that ... ironically

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

3059773

!
0
 
LVL 75
ID: 39878323
Here we go !!

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

Finally !!!

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

mx
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 39878332
"i would like to specify the actual color value - what is the proper syntax?"

Me.lblSigned.BackColor = Val("&H" + "2EB03D")
0
 
LVL 75
ID: 39878349
Me.lblSigned.BackColor = Val("&H" + "InsertYourHexValueHere")
0
 

Author Comment

by:Karen Schaefer
ID: 39878362
Ok found a Hex to RGB converted and that did the trick.
0
 

Author Closing Comment

by:Karen Schaefer
ID: 39878366
thanks for the input.
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 39878404
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
 
LVL 75
ID: 39878434
:-)
"And you can even simply write it as:"
Well sure. I wrote it the other way for clarity ...
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now