473,624 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you change the background color of rows in top 25% of results?

99 New Member
Hi all,

I'm in Windows XP, Access 2007.

I need to create either a tabular subform or a list box that, from a query, returns a list of records showing amounts of money sorted in descending order. The top 25% of should have a background color or red; the next 25% should have a background color of yellow; the next 25% should have a background color of light blue; and the last 25% should have a background color of white.

I understand most of what I need to know to do this, but I don't know how to change the color of rows in a subform or list box, based on percentiles.

Has anyone seen any code like this?

-Thanks,
Adam
Nov 10 '09 #1
6 2333
Megalog
378 Recognized Expert Contributor
If you can use a subform in datasheet view, then I would use conditional formatting.

Set 3 conditions across all the fields to read:

Expression is [Percent]>0.75 (Set to red fill color)
Expression is [Percent]>0.5 And [Percent]<0.75 (set to yellow fill color)
Expression is [Percent]>0.25 And [Percent]<0.5 (set to light blue fill color)

"[Percent]" is whatever the field name is that you have formatted for percent values.

If neither of the 3 conditions are met, the fields will simply be the default background color, which would be white.

This works good in your case, since you can only have 3 conditional formats total. If you ever need to add a 4th case, then this would have to be done in vba somehow.

Personally, unless this needs to be in a form, I would do this formatting in a report instead.
Nov 10 '09 #2
AdamOnAccess
99 New Member
Hi Megalog,

Thanks for the response. I'm afraid this will need to be a form because once the user learns which records are at the top 25%, then they will need to be able to click and drill down into the records for more details.

I looked into the conditional formating. I have never used it before. It appears pretty straight forward. The only thing that throws me is this: When you are working on the detail section of a tabular form in design view, you only have 1 row of fields. I thought that once you set properties for that row, you can't alter the properties of separate rows during display.

Will conditional formating work in a tabular form for the detail records?
Nov 10 '09 #3
Megalog
378 Recognized Expert Contributor
Typically any properties you set to those fields will be reflected across all the records shown in a datasheet view. Conditional formatting is different though, and will separately format each record.
Nov 10 '09 #4
Megalog
378 Recognized Expert Contributor
Also, a small modification to the conditions I posted above... You should use a greater than or equal (>=), instead of greater than (>). Otherwise, .75, .5, and .25 wont trigger conditions. So, use this instead:

Expression is [Percent]>=0.75 (Set to red fill color)
Expression is [Percent]>=0.5 And [Percent]<0.75 (set to yellow fill color)
Expression is [Percent]>=0.25 And [Percent]<0.5 (set to light blue fill color)
Nov 10 '09 #5
mshmyob
904 Recognized Expert Contributor
Hello Adam.

Check out this demo I did that may help you. It uses continuous forms (tabular) and does what you are looking for with no limitations on the number of conditionals.

cheers,
Nov 10 '09 #6
AdamOnAccess
99 New Member
mshmyob,

Thanks again!

I'm almost up to that part of the application. I'll check out the sample when I start.

-Adam
Nov 10 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

10
5996
by: Richard | last post by:
The style sheet shown below is from the suckerfish vertical menu. http://www.htmldog.com/articles/suckerfish/dropdowns/example/vertical.html I've added in a few minor changes to color code the levels. I changed the width of the first level to 8em and get an unwanted space between that and the 2nd level. I'd like their to be no gap between the levels when I change the widths. What's to change to do this? Also, I do not understand the...
2
5290
by: RWD | last post by:
I am trying to figure out how to change the target frame in my hyperlink on a DHTML menu. The menu is in one frame and the target frame is called "main" The code is below: Thanks in advance RWD <script type='text/javascript'>
7
4840
by: Keith Smith | last post by:
How can I change the background IMAGE (not just color) of a CELL in a table? I know that I can do this using CSS, but I really need to be able to do it using JavaScript. Anyone know how? Must be able to change the image for each cell - not the whole table. Please help.
3
4744
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
4
4242
by: TJS | last post by:
can the rows and columns of a textarea element with an id be changed on the fly ? if so is there an example ?
0
3319
by: RSH | last post by:
I am working with the DataGridView control in a WinForm. I have written the code to change the background color of a cell after it is edited. I also change the color of the row (a different color) which allows users to see what cells and which rows have been edited. The problem is that whenever the user sorts the datagidview I lose the coloration...how can I go about making sure that the cells remained colored?
4
10747
by: HB | last post by:
So I have a table in ASP.NET <table runat="server" id="tblMyTable"> <tr> <td id="cellMyCell">word</td> </tr> </table> How do I reference the cell "cellMyCell" from the Vb.NET 1.1 code-behind to change the background color of the cell?
11
2353
by: free4trample | last post by:
First of all let me say that I know very little about javascript. what i need to do is to write a javascript functin which will change the background color of the table rows based on entrees in the table. See an example of the webpage that the script will work with here: http://igorpetrusky.awardspace.com/RunStats.html now, at the top there will be 3 buttons, which will call javascript functions that will operate on tables 2 through N. ...
6
3313
by: happyse27 | last post by:
Hi All, How do I change the height of the main menu as the height is inconsistent due to some of main menu's item stretches to 2 rows while, the other main menu's items are stretched to 1 row. Code is below Cheers... Andrew
0
8242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8681
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7170
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.