I am having a single ms access form with two unbound text boxes where I am showing two variants of PANTONE colors which are converted from Hex values to RGB (BGR) values in two public functions. I have about 2 thousand different colors.
The two Hex text boxes I have are named [tpx_hex] and [tcx_hex]. The two unbound text boxes are named [tpx_color] and [tcx_color].
My code (see below) works fine in a single form as shown below, but when I try to do the same in a continuous form then all the unbound textboxes turn black.
I would be grateful for some kind of guidance or a solution to my color issue.
Thanks in advance.
Private Sub Form_Current()
If IsNull(tpx_hex) Then
Exit Sub
Else
Me.tpx_color.BackColor = Color_tpx_Hex_To_Long([tpx_hex])
End If
If IsNull(tcx_hex) Then
Exit Sub
Else
Me.tcx_color.BackColor = Color_tcx_Hex_To_Long([tcx_hex])
End If
End Sub
Public Function Color_tpx_Hex_To_Long(strColor As String) As Long
Dim iRed As Integer
Dim iGreen As Integer
Dim iBlue As Integer
strColor = Replace(strColor, "#", "")
strColor = Right("000000" & strColor, 6)
iBlue = Val("&H" & Mid(strColor, 1, 2))
iGreen = Val("&H" & Mid(strColor, 3, 2))
iRed = Val("&H" & Mid(strColor, 5, 2))
Color_tpx_Hex_To_Long = RGB(iBlue, iGreen, iRed)
End Function
Public Function Color_tcx_Hex_To_Long(strColor As String) As Long
Dim iRed As Integer
Dim iGreen As Integer
Dim iBlue As Integer
strColor = Replace(strColor, "#", "")
strColor = Right("000000" & strColor, 6)
iBlue = Val("&H" & Mid(strColor, 1, 2))
iGreen = Val("&H" & Mid(strColor, 3, 2))
iRed = Val("&H" & Mid(strColor, 5, 2))
Color_tcx_Hex_To_Long = RGB(iBlue, iGreen, iRed)
End Function
