By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,466 Members | 1,741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,466 IT Pros & Developers. It's quick & easy.

Change Colour in Combo Box

P: n/a
Help !
Have a combo box in accsess, with 6 fields, I want each to show up a
different colour when they ar selected/viewed. I have tried the
following code but seems to have no affect can anyone help? (Combo54,
is the name of my combo box, and the cases being "Software" etc, is
the data entered into this table. The table is called type, and the
column this data is entered is also called type. I also have an auto
number column called Type Number.

Private Sub Combo54_AfterUpdate()

Select Case Me!Combo54
Case "Printer Driver"
Me!Combo54.ForeColor = [Red]
Case "Software"
Me!Combo54.ForeColor = [Black]
Case "Operating/Network System"
Me!Combo54.ForeColor = [Magneta]
Case "General Driver"
Me!Combo54.ForeColor = [Yellow]
Case "Patch/Update/SP"
Me!Combo54.ForeColor = [Green]
Case "Lab Software"
Me!Combo54.ForeColor = [Cyan]
End Select
End Sub
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
If I understand what you want correctly, this is how I did the same thing.
Your mileage may vary.
Private Sub cboColorCode_Enter()
Me.cboColorCode.ForeColor = BLACK
Me.cboColorCode.BackColor = WHITE
End Sub

Private Sub cboColorCode_AfterUpdate()
With Me.cboColorCode
If IsNull(Me("cs_color_code")) Then
Me("cs_color_code") = 0
.Requery
.ForeColor = BLACK
.BackColor = WHITE
Else
.ForeColor = .Column(2)
.BackColor = .Column(3)
End If
End With
End Sub
cboColorCode RowSource:

SELECT color_id, color_name, color_fore, color_back FROM lu_color_code ORDER
BY lu_color_code.color_id;
Table lu_color_code
______________________________
color_id color_name color_fore color_back
0 N/A 0 16777215
1 Black 16777215 0
2 Blue 16777215 16711680
3 Green 65535 32768
4 Orange 0 33023
5 Purple 16744703 8388736
6 Red 16777215 255
7 Yellow 16711680 65535
When the form loads, the code from cboColorCode_AU is called to set the
initial color.
Darryl Kerkeslager


"Dwight" <dw*******@hotmail.com> wrote:
Help !
Have a combo box in accsess, with 6 fields, I want each to show up a
different colour when they ar selected/viewed. I have tried the
following code but seems to have no affect can anyone help? (Combo54,
is the name of my combo box, and the cases being "Software" etc, is
the data entered into this table. The table is called type, and the
column this data is entered is also called type. I also have an auto
number column called Type Number.

Private Sub Combo54_AfterUpdate()

Select Case Me!Combo54
Case "Printer Driver"
Me!Combo54.ForeColor = [Red]
Case "Software"
Me!Combo54.ForeColor = [Black]
Case "Operating/Network System"
Me!Combo54.ForeColor = [Magneta]
Case "General Driver"
Me!Combo54.ForeColor = [Yellow]
Case "Patch/Update/SP"
Me!Combo54.ForeColor = [Green]
Case "Lab Software"
Me!Combo54.ForeColor = [Cyan]
End Select
End Sub

Nov 13 '05 #2

P: n/a
Rob
This will work as long as what's on the right side ([Red]) evaluates
to a color constant. (I would use vbRed, or 255).
A side effect of doing this is that when the user clicks on the combo
box the color of ALL the items in the list will be the color of the
currently selected value in the combo box.
ROb

dw*******@hotmail.com (Dwight) wrote in message news:<f0**************************@posting.google. com>...
Help !
Have a combo box in accsess, with 6 fields, I want each to show up a
different colour when they ar selected/viewed. I have tried the
following code but seems to have no affect can anyone help? (Combo54,
is the name of my combo box, and the cases being "Software" etc, is
the data entered into this table. The table is called type, and the
column this data is entered is also called type. I also have an auto
number column called Type Number.

Private Sub Combo54_AfterUpdate()

Select Case Me!Combo54
Case "Printer Driver"
Me!Combo54.ForeColor = [Red]
Case "Software"
Me!Combo54.ForeColor = [Black]
Case "Operating/Network System"
Me!Combo54.ForeColor = [Magneta]
Case "General Driver"
Me!Combo54.ForeColor = [Yellow]
Case "Patch/Update/SP"
Me!Combo54.ForeColor = [Green]
Case "Lab Software"
Me!Combo54.ForeColor = [Cyan]
End Select
End Sub

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.