Approach User Support homepage Approach User Support
Answers to Frequently Asked Questions about Lotus Approach
Examples LotusScripts
Example databases
Links to other Lotus Approach support services

[Return to contents]

Displaying Negative Values In Red (Changing fonts colours using LotusScript)

Last updated: 20 Dec 1999

In v2.1 and v3.0*: you need to create 2 calculated fields: one that will only display the number if it is negative: If(DB.NUMBER < 0, DB.NUMBER, ''), and the other that will only display the number when it is positive: If(DB.NUMBER >= 0, DB.NUMBER, '')

Display these fields on your report or form. Set the Fill Color to transparent on both of them, and the Pen Color to red on the field that will display the negative values. Then use the OBJECT / ALIGNMENT menu item to place one of the fields directly on top of the another. Set the STYLE / FIELD STYLE / LABEL: to be blank, and create a separate text box to label the field if required.

In v96: you can either use the same method outlined for v2.1 and v3.0* shown above, or the following LotusScript attached to the field wherever it is displayed:

Sub Lostfocus(Source As Fieldbox)
    If Val(CurrentView.Body.YourFieldName.Text) <= 0 Then
        currentview.Body.YourFieldName.font.color.setrgb(color_red)
    Else
        currentview.Body.YourFieldName.font.color.setrgb(color_black)
    End If
End Sub

To change the background colour, use:

   currentview.Body.YourFieldName.background.color.setrgb(color_red)

[Return to contents]

© Copyright, JohnBrown, Trademarks, Disclaimer, Acknowledgements.