473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Change Colour in Combo Box

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
2 6457
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steve | last post by:
I have some standard toolbars on some of my screens and they are standard grey. Problem is the rest of our app is light blue, and they look out of place. Is there a way of changing the colour of...
1
by: amber | last post by:
Hi there, I'd like to change the colour of my tabs. I can change my background colour of my tab control, but the actual tabs, with the text on them don't change colour. Am I missing something?...
1
by: CodeRazor | last post by:
Hi, I am using a CrystalReportViewer to display my report. The DisplayToolbar property is set to true. This displays a dark grey toolbar with navigation buttons etc. Is it possible to change...
4
by: gurdz | last post by:
Does anyone know how to change the colour of the text in the console in C??
0
by: satish | last post by:
I have a table with two columns field1 int,Field2 and added a column to datagrid on runtime sum (field1+field2) ,upon changing the data in either of the fileds the sum field or column too changes ....
1
by: satish | last post by:
I have a table with two columns field1 int,Field2 and added a column to datagrid on runtime sum (field1+field2) ,upon changing the data in either of the fileds the sum field or column too changes ....
9
by: OllyJ | last post by:
Hi guys, I have a continuous form and one field is Day / Night, where a 'D' or 'N' is contained to represent each. Is it possible to write code for the 'on current' of the form to ensure a box...
7
by: Nasher | last post by:
i have a combo box (combo box 1) in a form header that users use to selct item numbers from. I also have a combo box (combo box 2) that users use to select a priority number (1,2,3) for that item....
0
by: muddasirmunir | last post by:
If we use manifest.exe in our folder, it will give our application XP look , and the default colour its shws is blue , can we change this colour to some other colours and if so how?
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.