Color Codes Decipherable?

  • Thread starter Thread starter croy
  • Start date Start date
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?
 
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?
 
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.
 
Back
Top