Solved

How can I change the background colour for a specific row in a table

Posted on 2014-10-17
6
516 Views
Last Modified: 2014-10-20
How can I change the background colour for a specific row in a table, based upon the string value in one of the fields. eg If the original data in one of the tables rows is edited one of the fields will have the string Amend entered. I would then like the row in that table to be coloured orange (a simple visual indicator for the end user that something has changed.)

Please be patient with me as an access newbie..
Thanks for reading
0
Comment
Question by:mrmad1966
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 34

Expert Comment

by:ste5an
ID: 40386252
There is no simple way to do this.

What Access version and what kind of "table" are you talking about?
0
 
LVL 48

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 40386263
You cannot do this in a table, but you could do it for a record displayed in a form or a report, using conditional formatting.  This is easiest to do for a single control on your form or report, but could be extended to the entire row.  

1.  Open your continuous or datasheet form in design view.
2.  Select the control that you want to flag with this color coding
3.  On the Ribbon, click design, then Conditional Formatting from the Font section (this is in 2007), I believe there is a Format tab in the Ribbon for 2010.
4.  Where it says Condition 1, select "Expression Is"
5.  In the box to the right enter a criteria that must be met for this conditional formatting to display.  In your case this might look something like:

Right("     " & [SomeFieldName], 5) = "AMEND"

6.  Then select your background color, and click OK.

Note: in the above syntax, I added 5 spaces to the beginning of the field to ensure that there are at least 5 characters in the string being tested.
0
 
LVL 37

Expert Comment

by:PatHartman
ID: 40386781
The simplest way to do it for an entire row is to create a textbox that spans the entire row and move it behind the other controls.  Set the other controls to be transparent.  Then you can control the color of the background control and that will change the background for all the "front" controls.

This method does not work on a datasheet form but it will work on a continuous or single view form or on a report.
0
Webinar: Security & Encryption in the MySQL world

Join Percona’s Solutions Engineer, Dimitri Vanoverbeke as he presents “Security and Encryption in the MySQL world” on Thursday, July 6, 2017 at 7:00 am PDT / 10:00 am EDT (UTC-7).

 
LVL 50

Expert Comment

by:Gustav Brock
ID: 40388673
Pat, it will do that for all records, not a specific one.

The olde trick is to set the foreground colour of that textbox and then bind it to a function that returns Null for common records and a bunch of the White Space character for the specific record.

gustav
0
 
LVL 37

Expert Comment

by:PatHartman
ID: 40390524
Conditional formatting only affects the current record.  I guess I didn't make it clear that we were still talking about using conditional formatting.  You use the "Expression Is" option but attach it to the field you want to color rather than the field you want to examine.

I forgot about the olde trick it's been so long since I had to use it.  Too bad even that won't work for DS view.  In DS view, the only option is to colorize each control independently because you can't use the stacked controls trick.

While we're at it, it's also too bad that the conditional formatting option doesn't use theme colors.  You have to be careful so you don't conflict with the theme you are using.  The results can be jarring.
0
 
LVL 1

Author Closing Comment

by:mrmad1966
ID: 40391840
Thank you everyone.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question