Change textbox color based on another textbox value

UPachqge

New member
Local time
Yesterday, 22:17
Joined
Jun 22, 2011
Messages
9
Hello,

I've created a form which displays a total "banked time" time value from a number of records. New records are created to add or subtract banked time in minutes. I've run into a problem where when more time is subtracted than a person has accrued (eg. borrowing an hour of time to make up at a later date) and how to display this negative time value. I've done some research and have come to the conclusion it's not possible for a text box with an input mask for time to display a negative time value.

What I'm hoping is possible, and what I need assistance with, is changing the color of text, in a text box, based on another text box value. One text box, [Text.Minutes], displays a plain text, unformatted total number of minutes (positive or negative). I would like for my [Text.Hours] box to reference this number and change it's text color to red, if it is a negative value.

Is this at all possible? Is there an easier way to go about displaying "negative" time?

Edit:

I did some additional Googling and have discovered one can set a text box to have conditional formatting. This seems to work but I've found that when entering a new record, the text box values do not update until I close and reopen the form.

Is there any way to do this without conditional formatting or any way to do this with conditional formatting but have my records update in real time like without?

Edit 2:
A simple refresh button fixes this so my problem is solved... I'm still curious if there is a VB way of doing this.
 
Last edited:
Try This:
The Header also has a image that changes as well but only when it has to! Note that you can not assign HexiDecimal values now used by MS.

Code:
Private Function OriginalsFeatures()

    With CodeContextObject
        If Forms![Menu]![Company Region] = "L" Then
            If Not IsNull(.[Orig 3rd Party]) Or .[Orig Supplier Vat Code] <> 0 Then
                .[Orig Sell Net].BackColor = 8388608
                .[Orig Sell Net].ForeColor = 16777215
                .[Orig Sell].BackColor = 16777215
                .[Orig Sell].ForeColor = 0
            ElseIf (IsNull(.[Orig 3rd Party ]) Or .[Orig Supplier Vat Code] = 0) Then
                .[Orig Sell].BackColor = 8388608
                .[Orig Sell].ForeColor = 16777215
                .[Orig Sell Net].BackColor = 16777215
                .[Orig Sell Net].ForeColor = 0
            End If
        End If

        If .[Orig Stock Status] = "P" And .[StockStatus] <> "P" Then
            .[Header_Originals].Picture = "C:\Databases\Livery\Header_Originals_Purchase.gif"
            .[StockStatus] = "P"
        ElseIf .[Orig Stock Status] = "H" And .[StockStatus] <> "H" Then
            .[Header_Originals].Picture = "C:\Databases\Livery\Header_Originals_History.gif"
            .[StockStatus] = "H"
        ElseIf .[Orig Stock Status] = "C" And .[StockStatus] <> "C" Then
            .[Header_Originals].Picture = "C:\Databases\Livery\Header_Originals.gif"
            .[StockStatus] = "C"
        End If
    End With
End Function

Simon
 

Users who are viewing this thread

Back
Top Bottom