Sometimes you might want to highlight a field on your report in a different colour depending on a particular condition. In the example below we are adding script to the report Detail section on the BeforePrint event. 


This script will highlight the CustomerName field in RED if the Balance field is greater than the CreditLimit.


Sub OnBeforePrint()

  if rpt.sections("Detail").controls("Balance").text > rpt.sections("Detail").controls("CreditLimit").text then

    rpt.sections("Detail").controls("CustomerName").forecolor = rgb(255,0,0)

  else

    rpt.sections("Detail").controls("CustomerName").forecolor = rgb(0,0,0)

  end if

End Sub