Combo Box - change colours

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to make the text in a combo box different colors, depending on the
status field I have - is there a way to do this

Thanks in advanced
 
Hi, Kuraige.

Sure. Change it via a Select Case statement and by changing the ForeColor
property. You will need to put this code in the form's OnCurrent event
procedure and the Status AfterUpdate event procedure:

Select Case Me!Status
Case firstcase
' Change to Red
Me!YourTextBoxName.ForeColor = 255
Case secondcase
' Change to Bright Green
Me!YourTextBoxName.ForeColor = 65280
Case thirdcase
' Another case
....
Case Else
' Put default color here
End Select

To determine the appropriate color codes, simply select a color in form
design view, and see how Access changes the ForeColor property.

HTH
Kevin Sprinkel
 
Try


Select Case Me!StatusField
Case a
me!ComboBox.ForeColor = 8454143

Case b
me!ComboBox.ForeColor = 16777215

etc ......
End Select


You will have to work out when you want to catch the change of record.

The difficult part is finding out what number corresponds to the
colour you want. The best way is to set the colour of the control
manually using the color builder on the property sheet, and copying
the number into your code.
 
Great Idea

Thanks for the help

Sprinks said:
Hi, Kuraige.

Sure. Change it via a Select Case statement and by changing the ForeColor
property. You will need to put this code in the form's OnCurrent event
procedure and the Status AfterUpdate event procedure:

Select Case Me!Status
Case firstcase
' Change to Red
Me!YourTextBoxName.ForeColor = 255
Case secondcase
' Change to Bright Green
Me!YourTextBoxName.ForeColor = 65280
Case thirdcase
' Another case
....
Case Else
' Put default color here
End Select

To determine the appropriate color codes, simply select a color in form
design view, and see how Access changes the ForeColor property.

HTH
Kevin Sprinkel
 
Thanks guys

ths almost does what I need but I am not sure if this is possible or not -
but the code here will change all the list to the same color - is there a way
to display the color for that record that meets the requirements only and the
next record if the status is differnt display in a differnt color. all inside
the combo box

Thanks again guys
 
There's no way to give some of the rows in the combo box one color and others
another (that I know of, anyway--you may want to check Steve Lebans'
website), but the simple way is just to filter the combo box so that it
displays only those rows you want. You do this by changing the combo box'
Row Source property, in the same places where you're changing the forecolor:

Me!YourComboBox.RowSource = <sql statement>

For example, assuming you'd be filtering by the value of the status field,
and that the rows are in a table named Options, something like:

Me!YourComboBox.RowSource = "SELECT Options.ID, Options.Description FROM
Options WHERE Options.Status = Me!Status"

HTH
Sprinks
 
Forgot to mention--after changing the Row Source, you'll need to requery the
combo box:

Me!YourComboBox.Requery

Sprinks
 
Back
Top