Formatting a "field" in report based on date

Montez659

Well-known Member
Joined
May 4, 2005
Messages
918
Is it possible when generating a report based off of a query to either highlight or change the color of the text of a certain field based on it's value? For instance, the report being generated from the query pulls in the estDueDate and I would like to make this the color red if it is greater than today.

Thanks in advance for all the help past, present, and future!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
In the Detail or Group Header of wherever you have your date field put this in the On Print event (or possible the On Format event)

Code:
If Nz(me.estDueDate,#11/11/1111#) > Date() then
  me.estDueDate.ForeColor = vbRed
Else
 me.estDueDate.ForeColor = vbBlack
End If

hth,

Rich
 
Upvote 0
Rich,

Not quite getting that to work. My texbox is in the Detail area of the report, and I tried it in both the On Print and On Format function, as code and as an expression and none of these have worked. Your code looks good, so what am I doing wrong?

EDIT: Got it to work in the On Paint method. Thanks for the help!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,956
Messages
6,122,465
Members
449,085
Latest member
ExcelError

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top