Color Codes Decipherable?

C

croy

What is the basis for the color codes in Access?

If I pick a color from the limited pallete, and it's close
to what I want, could I know how to alter the code to make
it, for instance, just a bit lighter?
 
D

Dirk Goldgar

croy said:
What is the basis for the color codes in Access?

If I pick a color from the limited pallete, and it's close
to what I want, could I know how to alter the code to make
it, for instance, just a bit lighter?


The negative color codes are system-defined colors. Non-negative ones are
RGB values, constructed from red, green, and blue parts. There's an RGB
function that you can call to assemble specific values (0 to 255) for each
of the parts into a single color value. Here are functions I just threw
together to deconstruct a color value into its component parts:

'----- start of code -----
Function fncReverseRGB(ColorValue As Long) As String

Dim iRed As Integer
Dim iGreen As Integer
Dim iBlue As Integer

If ColorValue < 0 Then
fncReverseRGB = "system-defined color"
Else
fncReverseRGB_ByRef ColorValue, iRed, iGreen, iBlue
fncReverseRGB = iRed & "," & iGreen & "," & iBlue
End If

End Function

Function fncReverseRGB_ByRef( _
ColorValue As Long, _
ByRef RedValue As Integer, _
ByRef GreenValue As Integer, _
ByRef BlueValue As Integer)

RedValue = ColorValue And &HFF
GreenValue = (ColorValue And &HFF00&) \ 256
BlueValue = ColorValue \ 65536

End Function
'----- end of code -----

You are aware that for most objects, Access provides a means to set a custom
color that is far more complex than the "limited palette" that you see at
first?
 
L

Linq Adams via AccessMonster.com

There probably is, but I've never come across it. If you selectt he control
or form section in question and goto

Properties - Format

and click in the BackColor property, for example, an ellipsis (...) will
appear. Click on this and you will get an extended pallet which includes a
command button

Define Custom Colors

It lets you do just that, blend custom colors. Once you've done this, the new
color will appear as part of the pallet.

Note that you have to pull up the pallet as I've instructed. The pallet you
get by
Right Clicking - BackColor is a limited one and doesn't offer this option.
 
C

croy

The negative color codes are system-defined colors. Non-negative ones are
RGB values, constructed from red, green, and blue parts. There's an RGB
function that you can call to assemble specific values (0 to 255) for each
of the parts into a single color value. Here are functions I just threw
together to deconstruct a color value into its component parts:

'----- start of code -----
Function fncReverseRGB(ColorValue As Long) As String

Dim iRed As Integer
Dim iGreen As Integer
Dim iBlue As Integer

If ColorValue < 0 Then
fncReverseRGB = "system-defined color"
Else
fncReverseRGB_ByRef ColorValue, iRed, iGreen, iBlue
fncReverseRGB = iRed & "," & iGreen & "," & iBlue
End If

End Function

Function fncReverseRGB_ByRef( _
ColorValue As Long, _
ByRef RedValue As Integer, _
ByRef GreenValue As Integer, _
ByRef BlueValue As Integer)

RedValue = ColorValue And &HFF
GreenValue = (ColorValue And &HFF00&) \ 256
BlueValue = ColorValue \ 65536

End Function
'----- end of code -----

You are aware that for most objects, Access provides a means to set a custom
color that is far more complex than the "limited palette" that you see at
first?


Very nice answer! Thanks.
 
Top