[control].ForeColor - for the text in a text box, combo box, list box, or label - the foreground color.
[control].BackColor - for the background color of the above items
[control].BorderColor - for the color for the line around the items.
For things like radio buttons and toggle buttons, you won't find all three of those items. Lines, for example, only have a border color. Buttons generally don't have a foreground color. As a side note, if you select a control format such as "shadowed" then the size and color of the shadow can be controlled using the border color and border size properties.
You can set any of these colors to the following constants:
or you can look up the RGB function in the help files to see how to customize any color you wish.
finally, you can look up in the help files to find the System Color Constants. Things like vbDesktop = the color of your desktop. vbMenuBar = the color of your menu's background color. vbActiveBorder = the color of the border on your active window. Etc. etc.
Using the latter constants usually means that your Access application follows the default color scheme of your Desktop setup. Sometimes this even works nicely. However, usually you don't want to mix the Desktop settings and custom settings because you could get some really PUTRID combinations as a result. Some folks have the darnedest color schemes I've ever seen. So be careful about using these schemes unless you want to get some really nasty comments from folks with any sense of color at all.
Now as to WHERE to set these properties, you have to decide when they would be set any when/if the setting becomes dynamic. Most folks will either use the Form_Load event (for relatively static settings) or the {control}_GetFocus / _LostFocus events (for relatively dynamic settings.) This is something that MUST be done using VBA if you really want to do your color changes based on criteria. But it is pretty easy. I do it all the time, usually in my case with the _GetFocus / _LostFocus code.
I had a read on this thread w w w.access-programmers.co.uk/forums/showthread.php?t=34499 (please remove the spaces)
which helped me alot! however I'm come across a problem on my side. I've made a database where you input relevant information when a customer comes in store to enquire about products (you enter in their information, what they enquired about and a quotation). Then there is a series of check boxes where if the enquiry has been solved then you tick the box, if the enquiry is on going then you tick the solved box and the on going box, if the enquiry is closed and no further action needed then you tick on the solved, on going and no further action box.
As you move through and check the relevant boxes you press on a button called "process enquiry" (this is where I have the problems). Depending on what check boxes are ticked the colours change, for example red is a no go, yellow is a maybe and green is a go.
I've coded the button to change the boxes based on what is ticked, (if all 3 are ticked then red, if two are ticked then yellow and if one is ticked then green).
Now the problem I have is that the colours change for every single record in my form. So if record 2 is yellow and record 3 and green then both of them change to the same colour. How can I change it so each record changes independetly based on what is ticked ?
Here is how my code looks below (I've included some of it, not all of it)
Code:
Private Sub Process_Enquiry_Click()
If Tickbox_Actioned = True And Tickbox_ChasedUp = True And Tickbox_Forget = True Then [EnquiryBox].ForeColor = vbRed Else If Tickbox_Actioned = True And Tickbox_ChasedUp = True Then [EnquiryBox].ForeColor = vbYellow Else If Tickbox_Actioned = True Then [EnquiryBox].ForeColor = vbGreen Else [EnquiryBox].ForeColor = vbWhite
If Tickbox_Actioned = True And Tickbox_ChasedUp = True And Tickbox_Forget = True Then [QuotationBox].ForeColor = vbRed Else If Tickbox_Actioned = True And Tickbox_ChasedUp = True Then [QuotationBox].ForeColor = vbYellow Else If Tickbox_Actioned = True Then [QuotationBox].ForeColor = vbGreen Else [QuotationBox].ForeColor = vbWhite
End
End
End Sub
If required I can put up a picture of the form
My question to you guys is how can i code the button so that when i click on it, it changes each record individually and not every single one.
[control].ForeColor - for the text in a text box, combo box, list box, or label - the foreground color.
[control].BackColor - for the background color of the above items
[control].BorderColor - for the color for the line around the items.
For things like radio buttons and toggle buttons, you won't find all three of those items. Lines, for example, only have a border color. Buttons generally don't have a foreground color. As a side note, if you select a control format such as "shadowed" then the size and color of the shadow can be controlled using the border color and border size properties.
You can set any of these colors to the following constants:
or you can look up the RGB function in the help files to see how to customize any color you wish.
finally, you can look up in the help files to find the System Color Constants. Things like vbDesktop = the color of your desktop. vbMenuBar = the color of your menu's background color. vbActiveBorder = the color of the border on your active window. Etc. etc.
Using the latter constants usually means that your Access application follows the default color scheme of your Desktop setup. Sometimes this even works nicely. However, usually you don't want to mix the Desktop settings and custom settings because you could get some really PUTRID combinations as a result. Some folks have the darnedest color schemes I've ever seen. So be careful about using these schemes unless you want to get some really nasty comments from folks with any sense of color at all.
Now as to WHERE to set these properties, you have to decide when they would be set any when/if the setting becomes dynamic. Most folks will either use the Form_Load event (for relatively static settings) or the {control}_GetFocus / _LostFocus events (for relatively dynamic settings.) This is something that MUST be done using VBA if you really want to do your color changes based on criteria. But it is pretty easy. I do it all the time, usually in my case with the _GetFocus / _LostFocus code.
It should be noted that another way exists to answer the original question. There IS such a thing as conditional formatting, where you can define a condition and the color scheme that goes with each condition (from TWENTY years ago...).
You can set conditional formatting rules for controls on a form or report in Access desktop databases to highlight important data.
support.microsoft.com
I'm not going to swear to this, but the conditional formatting options might not have been available back then. But if they were, at the time of my original answer, I didn't know them.
It should be noted that another way exists to answer the original question. There IS such a thing as conditional formatting, where you can define a condition and the color scheme that goes with each condition (from TWENTY years ago...).
You can set conditional formatting rules for controls on a form or report in Access desktop databases to highlight important data.
support.microsoft.com
I'm not going to swear to this, but the conditional formatting options might not have been available back then. But if they were, at the time of my original answer, I didn't know them.