Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing backcolor of combobox

Status
Not open for further replies.

JOD59

Technical User
Dec 17, 2003
39
US
I have a combo box that I want to change the back color depending on the selection made. I have the code working but my problem is that when I switch records the color from the previous record remains. Is there a way to reset it to the default color? I'm some what new to all the coding options for VB thanks for any help

Example of my code so far

Private Sub cboElecSafeClass_AfterUpdate()
If Me.cboElecSafeClass.Value = "Action Requiered" Then
Me.cboElecSafeClass.BackColor = 65535
Else
If Me.cboElecSafeClass.Value = "Action Complete" Then
Me.cboElecSafeClass.BackColor = 65280
Else
If Me.cboElecSafeClass.Value = "No Action Requiered" Then
Me.cboElecSafeClass.BackColor = -2147483633
End If
End If
End If
End Sub
 
Try moving your code from combobox_AfterUpdate to a separate Sub in your Form, such as
Sub SetcboElecSafeClassBackColor.

In the After Update event of the combobox AND in the On Curent event of the Form call this sub.

Hope this helps.
 
How are ya JOD59 . . . . .

Sounds like a [blue]Continuous Form[/blue].

If Access 2k or higher, have a look at [blue]Conditional Formatting[/blue]!

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top