none
Change a text box colour on a report RRS feed

  • Question

  • Hi all,

    I need the fore colour of a textbox on a report to change depending the outcome of certain criteria. In this case, if the "DaysLeft" is les than zero, the forecolor must change to RED, else it must remain the default (Black).

    I added the code in the "On Load" event, but the colour of all the lines is changed to whatever the first record results to. I need each and every record to be checked and the fore colour changed according to that record.

    Any suggestions?

    Thanks

    Monday, January 7, 2019 10:59 AM

Answers

  • You can do this without code:

    • Open the report in design view.
    • Select the text box.
    • Activate the Format tab of the ribbon (under Report Design Tools).
    • Click 'Conditional Formatting' in the 'Control Formatting' group.
    • Click 'New Rule'.
    • Leave the first dropdown set to 'Field Value Is'.
    • Select 'less than' from the second dropdown.
    • Enter 0 in the box next to it.
    • Click the 'Font color' dropdown.
    • Select red.
    • Click OK.

    If you prefer to use code, use the On Format event of the Detail section of the report instead of the On Load event of the report itself.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by Deon SA Monday, January 7, 2019 11:33 AM
    Monday, January 7, 2019 11:14 AM

All replies

  • You can do this without code:

    • Open the report in design view.
    • Select the text box.
    • Activate the Format tab of the ribbon (under Report Design Tools).
    • Click 'Conditional Formatting' in the 'Control Formatting' group.
    • Click 'New Rule'.
    • Leave the first dropdown set to 'Field Value Is'.
    • Select 'less than' from the second dropdown.
    • Enter 0 in the box next to it.
    • Click the 'Font color' dropdown.
    • Select red.
    • Click OK.

    If you prefer to use code, use the On Format event of the Detail section of the report instead of the On Load event of the report itself.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by Deon SA Monday, January 7, 2019 11:33 AM
    Monday, January 7, 2019 11:14 AM
  • Thanks Hans - conditional formatting did not even cross my mind!!

    Regards

    Monday, January 7, 2019 11:33 AM