Avatar of mlcktmguy
mlcktmguy
Flag for United States of America asked on

Color Numbers For Screen Background

I like ot have my screen backgroun color stored (and set) in a module that is referened by all screens in the Form Load event.  This way if the user changes their mind or I want to change the backgroun color of all screens I do it in one place.

Since I am using code to set the color I must specify the corresponding color with numbers,  such as:

Public Const cFormBackcolor As Long = 15784923   'pale blue

I know that vbRed, vbBlack etc.. can be used but the user will usually specify something more custom.  Is there any way to detrmine the numerical equivalent of a color?   I'm guessing the numbers somehow break down into a red, green and blue component.  Can I create a color in the custom pallette of the color selector and soemhow know what number corresponds to that color?

Private Sub Form_Load()
Update_Form_Controls Me
End Sub

Open in new window

Microsoft Access

Avatar of undefined
Last Comment
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

8/22/2022 - Mon
Zeiramrei

Colors can be broken down into decimal form, with 3 sets of numbers.

Red   Grn   Blue
000, 000, 000

The bigger the number in that group, the more of that color.

You can get a break down here: http://www.december.com/html/spec/colordec.html
wiswalld

This is for font and not for a module but maybe you can modify to what you want.
wiswalld

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
tristancomputes

Hi there,

You can check out this website for a full breakdown:
http://www.acasystems.com/en/color-picker/faq-vb-color.htm

Basically, you can specify any RGB colour in hex form by using 0xBBGGRR.  If you are familiar with HTML colouring system, you can use the attached code to convert between the two.

If you want a quick guide on what HTML code you can use for each colour, check out this link:
http://www.visibone.com/color/hexagon_800.gif

Hope this helps you out.
Private Function CvtColorVB2Web(colorcode As String) As _
    String
Dim vcolor
    vcolor = Hex(Val(colorcode))
    If Len(vcolor) < 6 Then
       vcolor = String(6 - Len(vcolor), "0") & vcolor
    End If
    CvtColorVB2Web = Mid(vcolor, 5, 2) & Mid(vcolor, 3, 2) _
        & Mid(vcolor, 1, 2)
End Function
 
Private Function CvtColorWeb2VB(colorcode As String) As _
    String
    If Len(colorcode) < 6 Then
       colorcode = colorcode & String(6 - Len(colorcode), _
           "0")
    End If
    CvtColorWeb2VB = "&H" & Mid(colorcode, 5, 2) & _
        Mid(colorcode, 3, 2) & Mid(colorcode, 1, 2)
End Function

Open in new window

mlcktmguy

ASKER
Database MX has the most direct and easy to implement solution.
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

Note: Any custom color created in the pallet is only good for the Access session you are in.  Once you close Access and re-open ... those custom colors are gone from the list in the Pallet (but not on a Form/Report)

mx
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.