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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change font color based on a criteria in a report

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I would like to identify those records in an inventory with qty on hand less than the reorder amount to appear red. All other records should appear black. Is there a method to do this?
 
jem,

The below is an example of how to change the background color on alternating lines. You can easily adapt it to change the foreground color of the controls on the line, and to change the color to RED or BLACK, depending on your condition, as opposed to the simple line counter approach.

You need to carefully consider the environment where this will be used, as sending the report to a mono printer will result in little or no discrimination in the records. Also, even if the oriinal report is done in color, copies made in mono will - again - loose the discrimination. In my experience, a better soloution is to just set the bold attribute appropiatly, as it survives the mono printer and copier much more effectively.



Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    Dim Ctl As Control
    Static LineNo As Integer
    Const ltGrey = 16777215
    Const White = 12632256
    LineNo = LineNo + 1
    If ((LineNo Mod 2) = 0) Then        'Even number line, Shade it
        Me.Detail.BackColor = ltGrey
        For Each Ctl In Me.Detail.Controls
            Ctl.BackColor = ltGrey
        Next Ctl
     Else                               'Odd number line, No Shade
        Me.Detail.BackColor = White
        For Each Ctl In Me.Detail.Controls
            Ctl.BackColor = White
        Next Ctl
    End If
End Sub

MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top