UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Conditional Format Custom Color, Access 2010    
 
   
Caseythepenguin
post Sep 15 2019, 05:39 PM
Post#1



Posts: 2
Joined: 11-September 19



I am using Access 2010 and I have setup a continuous form. I have used the conditional formatting and have set a text box rule using a custom color, but I did not write down the RGB values for the custom color. If I go back and try to edit the rule to see the color, my custom color is not showing. I want to use the same colors in other forms but without knowing the custom color values I am lost. Does Access store those values in a hidden table or can I write code in vba to get those values?

Thanks
Go to the top of the page
 
jleach
post Sep 16 2019, 05:39 AM
Post#2


UtterAccess Editor
Posts: 10,154
Joined: 7-December 09
From: St Augustine, FL


Hi, welcome to UA.

Probably the first thing I would try is SaveAsText to see if you can pick the color out of there. You can access all of that via VBA also, but SaveAsText should put the whole form in a text output where it might be easier to find the control in question.

It's an undocumented function, but the arguments are pretty straightforward. I forget offhand what they are, but probably SaveAsText acForm, "MyForm", "C:\MyForm.txt" would do the trick.

hth

--------------------
Go to the top of the page
 
June7
post Sep 16 2019, 12:59 PM
Post#3



Posts: 889
Joined: 25-January 16



VBA can set and read Conditional Formatting rules and their settings. Example for reading:

CODE
Private Sub GetCF_Click()
    With Me.Rate.FormatConditions(0)
        Debug.Print .BackColor
        Debug.Print .FontBold
        Debug.Print .ForeColor
    End With

    With Me.Rate.FormatConditions(1)
        Debug.Print .BackColor
        Debug.Print .FontBold
        Debug.Print .ForeColor
    End With
End Sub

The output for colors is a long value which would have to be converted to RGB. See if this function gets correct output:
CODE
Function fcnLongToRGB(ByRef lngColor As Long) As String
Dim lngRed As Long, lngGreen As Long, lngBlue As Long
lngRed = lngColor Mod 256
lngGreen = (lngColor \ 256) Mod 256
lngBlue = (lngColor \ 256 \ 256) Mod 256
fcnLongToRGB = "RGB(" & lngRed & "," & lngGreen & "," & lngBlue & ")"
End Function

This post has been edited by June7: Sep 16 2019, 01:30 PM

--------------------
Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! http://www.cpearson.com/Excel/DebuggingVBA.aspx
Go to the top of the page
 
Caseythepenguin
post Sep 16 2019, 05:11 PM
Post#4



Posts: 2
Joined: 11-September 19



Thank you for your suggestions, I will give them both a try. thumbup.gif
This post has been edited by Caseythepenguin: Sep 16 2019, 05:12 PM
Go to the top of the page
 
strive4peace
post Sep 17 2019, 07:13 AM
Post#5


strive4peace
Posts: 20,459
Joined: 10-January 04



hi Casey,

more about color...

If you know an Access color number, you can break it down to its red, green, blue components

For instance, RGB(100, 150,200) = 13145700, which I will call ColorNumber

Red:
? ColorNumber mod 256
100

Green:
? int((ColorNumber mod 65536) / 256)
150

Blue:
? int( ColorNumber /65536)
200

if you have a hex value, which is 6496C8 for this example, and specified as #6496C8 on the property sheet, you can convert each couple from Hex to Long using CLng("&H" & HexValue) or to integer using CInt("&H" & HexValue) ... you can also use Int

Red:
?CLng("&H64") = 100
Green:
?CLng("&H96") = 150
Blue:
?CLng("&HC8") = 200

Another thing you can do is copy a color number to the color property of a control. Then, go to the color builder and look at what results for red, green, and blue



This post has been edited by strive4peace: Sep 17 2019, 07:21 AM

--------------------
have an awesome day,
crystal
Go to the top of the page
 
jleach
post Sep 17 2019, 07:53 AM
Post#6


UtterAccess Editor
Posts: 10,154
Joined: 7-December 09
From: St Augustine, FL


In addition, I find this website to be a superb reference for color-related information (including complimentary colors, etc):

https://www.color-hex.com/color/2e3f4c


--------------------
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    22nd October 2019 - 11:57 AM