If you are using Access 2000 or later, you can use Conditional Formatting.
Assuming the DaysLeft field holds the number of days left, then for each
control that you want to set to italics define conditional formatting as:
Condition 1 = "Expression Is" ... "[DaysLeft] > 0". Then click the Italics
button for the Condition 1 format.
For Access 97 and earlier, and assuming you want to italicize all the fields
in your detail section, then add the following code to your detail section's
Format event:
------------------------------
Dim ctl As Control
Dim blnSetItalics As Boolean
blnSetItalics = (Me.DaysLeft > 0)
For Each ctl In Me.Section(acDetail).Controls
ctl.FontItalic = blnSetItalics
Next ctl
------------------------------
The FontItalic only applies to certain types of controls (see help for
FontItalic) if you try setting it for illegal controls you will get an
error. If you want to set only some controls to italics, you could: Check
the control's ControlType property (see help) before setting FontItalic;
Call On Error Resume Next before setting FontItalic to just ignore any
error; or use the Tag property to identify the controls you want to
manipulate, as in the example below...
------------------------------
Dim ctl As Control
Dim blnSetItalics As Boolean
blnSetItalics = (Me.DaysLeft > 0)
For Each ctl In Me.Section(acDetail).Controls
If ctl.Tag = "Italics" Then ctl.FontItalic = blnSetItalics
Next ctl
------------------------------
Max said:
I have a report that shows outstanding issues. There is a
field that calculates the due days of an item. I would
like to italicize the whole record/line if the days are
positive. (+) means the item is outstanding (-) means
there is still time left.
Any assistance on code would be greatly appreciated.