Solved

Setting background color to specified value

Posted on 2014-02-21
15
323 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) 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 - Microsoft MVP, Access and Data Platform) 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

739 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