Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing color of row based on column value 1

Status
Not open for further replies.

herbal

Programmer
Jul 10, 2003
36
US
Can someone give me a quick rundown on how I would change the color of the text for a record if one column's value meets criteria?

Example...

My report contains Name, DOB, and Barred. Barred is the last column to be printed in a row(not sure if you needed to know this). If the value of Barred equals "Y" then I'd like that entire row to print in red, but if not I want it to print black like the rest.

Thanks in advance!

Herbal
 
Versions 2000+, use conditonal formatting.

Per the other controls, enter Format | Conditional Formatting, select "Expression is" in the first dropdown, enter the expression [Barred]="Y", select format... For the barred control, use the default selection in the dropdown, select "equal to" in the second, enter "Y", select format...

Roy-Vidar
 
Check out this recent thread: thread703-871700

Hoc nomen meum verum non est.
 
Here's a quick way. Click on the Detail bar in design view and on the On Print event place the following code:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If [Barred] = "Y" Then
Me.Detail.BackColor = 8454143
Else
Me.Detail.BackColor = vbWhite
End If
End Sub

It will turn the whole row yellow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top