Im trying to use some vb code in a form which simply changes font colours. It is for a stock control system. The stock control system includes three items: colour, stock and minimum stock.
The code is:
Private Sub Form_Current()
If Me.Colour = "Red" And Me.Minimum_Stock > Me.Stock Then
Me.Minimum_Stock.ForeColor = vbRed
ElseIf Me.Colour = "Green" And Me.Minimum_Stock > Me.Stock Then
Me.Minimum_Stock.ForeColor = vbGreen
ElseIf Me.Colour = "Blue" And Me.Minimum_Stock > Me.Stock Then
Me.Minimum_Stock.ForeColor = vbBlue
ElseIf Me.Colour = "Black" And Me.Minimum_Stock > Me.Stock Then
Me.Minimum_Stock.ForeColor = vbBlack
ElseIf Me.Colour = "Yellow" And Me.Minimum_Stock > Me.Stock Then
Me.Minimum_Stock.ForeColor = vbYellow
End If
End Sub
But im having a few problems, what happens is for example, if the colour black stock is greater then its minimum stock that stays black which it should but then if the blue minimum stock is greater then stock it goes blue which it should. The problem is now when i go back to the colour black it has turned blue. For some reason it is picking up the colour blue.
Does anyone have any ideas why and how to stop this?
The code is:
Private Sub Form_Current()
If Me.Colour = "Red" And Me.Minimum_Stock > Me.Stock Then
Me.Minimum_Stock.ForeColor = vbRed
ElseIf Me.Colour = "Green" And Me.Minimum_Stock > Me.Stock Then
Me.Minimum_Stock.ForeColor = vbGreen
ElseIf Me.Colour = "Blue" And Me.Minimum_Stock > Me.Stock Then
Me.Minimum_Stock.ForeColor = vbBlue
ElseIf Me.Colour = "Black" And Me.Minimum_Stock > Me.Stock Then
Me.Minimum_Stock.ForeColor = vbBlack
ElseIf Me.Colour = "Yellow" And Me.Minimum_Stock > Me.Stock Then
Me.Minimum_Stock.ForeColor = vbYellow
End If
End Sub
But im having a few problems, what happens is for example, if the colour black stock is greater then its minimum stock that stays black which it should but then if the blue minimum stock is greater then stock it goes blue which it should. The problem is now when i go back to the colour black it has turned blue. For some reason it is picking up the colour blue.
Does anyone have any ideas why and how to stop this?