/ Help centre
← All articles
End Users › General

How can I set the colour of a field in the DataPA Report Designer using script?

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…

Updated 23 March 2018

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


Need a hand?

We’re here if you need a little more help.

Contact support ↗