Color formatting and code for a combo box

Kryst51

Singin' in the Hou. Rain
Local time
Today, 17:00
Joined
Jun 29, 2009
Messages
1,896
Hi all,

I was trying to answer another thread, and came up with this example of how to formata the background of a combo box depending on what is selected in the list.

I got the background formatting to work. But when I tried to also included foreground formatting the code for the background messed up.

I am attaching my example, On the form the first combo box does not include the foreground change for the color "blue". The second combobox does include a foreground change for the color "blue". However when I select blue, instead of turning the foredgound white and the background blue, which is what I want, it turns the background black. The reason the foreground should be white is that when the background is blue, the text is hard to read.

I don't know enough about VBA to beable to tell what is going wrong. I appreciate any assistance given.

Edit: Also, is there a way to make the list for the combo box show white background with black text?
 

Attachments

Last edited:
You were on the right track. You just need to remove the And _ between the two lines:

Me.ComboBoxColorForgroundIssue.BackColor = 65535
Me.ComboBoxColorForgroundIssue.ForeColor = 0

These are two separate properties, so they each deserve their own line :) Should work for ya then.

As for the White background and Black text, just add White to your color table, and do the same thing. You can set the default to the ID number for white if you wish.
 
Thanks Scooterbug, works perfectly, I learned something new!

Here's the corrected Example for posterity's sake.

Edit: Scooterbug, I would love to give you reputation points, but I must "Spread some" around fist! LOL
 

Attachments

Users who are viewing this thread

Back
Top Bottom