Solved

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

Posted on 2014-10-17
6
497 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
6 Comments
 
LVL 32

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 47

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 34

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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 49

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 34

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now