A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Conditional formatting based on the value of another field



 
 
Thread Tools Display Modes
  #1  
Old August 26th, 2009, 01:46 PM posted to microsoft.public.access.reports
RSunday
external usenet poster
 
Posts: 83
Default Conditional formatting based on the value of another field

I have a report listing records. I would like the text part of a record to
change font color based on the value in another field of the same record.

How do I do that?
  #2  
Old August 26th, 2009, 04:09 PM posted to microsoft.public.access.reports
John Spencer
external usenet poster
 
Posts: 7,815
Default Conditional formatting based on the value of another field

What do you mean by the Text part? Are you referring to another textbox
control or are you referring to a label?

You can use conditional formatting on textbox controls, but not on label controls.

Guessing that you mean a text box control, then click on it, select
conditional formatting and use the Expression is option

Set your expression to something like

[AnotherField] = "My value"

Then set up you font color change.

If you need to do this with a label, you can convert the label to a textbox
control and set its control source to something like
="This is my label"

Or you can use VBA to change the font color of the label in the format event
of the section that contains the label

IF [AnotherField] = "My value" Then
ME.SomeLabel.ForeColor = vbRed
ELSE
ME.SomeLabel.ForeColor = vbBlack
END IF


John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

RSunday wrote:
I have a report listing records. I would like the text part of a record to
change font color based on the value in another field of the same record.

How do I do that?

  #3  
Old August 26th, 2009, 08:27 PM posted to microsoft.public.access.reports
RSunday
external usenet poster
 
Posts: 83
Default Conditional formatting based on the value of another field

You guessed right! And solved my problem. Thanks!

"John Spencer" wrote:

What do you mean by the Text part? Are you referring to another textbox
control or are you referring to a label?

You can use conditional formatting on textbox controls, but not on label controls.

Guessing that you mean a text box control, then click on it, select
conditional formatting and use the Expression is option

Set your expression to something like

[AnotherField] = "My value"

Then set up you font color change.

If you need to do this with a label, you can convert the label to a textbox
control and set its control source to something like
="This is my label"

Or you can use VBA to change the font color of the label in the format event
of the section that contains the label

IF [AnotherField] = "My value" Then
ME.SomeLabel.ForeColor = vbRed
ELSE
ME.SomeLabel.ForeColor = vbBlack
END IF


John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

RSunday wrote:
I have a report listing records. I would like the text part of a record to
change font color based on the value in another field of the same record.

How do I do that?


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:38 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.