Convert HTML Color code to Access Color Code

  • Thread starter Thread starter Malcolm Hind
  • Start date Start date
M

Malcolm Hind

I have HTML color codes stored in a DB - like '0000FF' (I
don't store the '#').

I want to set the Box.BackColor fill color of a rectangle to
the HTML color in an access database (rectangle is displayed
on a form) - I cannot find a way to get a color code from the
HTML code that Access can recognize ?

Any help appreciated.

Thanks
 
Function ConvertHTMLColor(HTMLColor As String) As Long
Dim strRed As String
Dim strGreen As String
Dim strBlue As String

If Len(HTMLColor) <> 6 Then
MsgBox HTMLColor & " is invalid."
Else
strRed = "&H" & Left$(HTMLColor, 2)
strGreen = "&H" & Mid$(HTMLColor, 3, 2)
strBlue = "&H" & Right$(HTMLColor, 2)
ConvertHTMLColor = RGB(CInt(strRed), CInt(strGreen), CInt(strBlue))
End If

End Function
 
Back
Top