Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If currency > X format yellow backcolor? 911!!!!!!

Status
Not open for further replies.

misscrf

Technical User
Jun 7, 2004
1,344
US
i have a textbox on a form called Amount. I am trying to have some code that will look at the currency amount, and if it is under $10, it will change the back color of the text box's label and the back color of the label. It doesn't seem to be working. I have the code on the form's on current and the field's after update.

Code:
Dim lngRed As Long
Dim lngBlack As Long
Dim lngYellow As Long

lngRed = RGB(255, 0, 0)
lngBlack = RGB(139, 137, 137)
lngYellow = RGB(255, 255, 0)


If Me!Amount.Value > 10 Then
    
    Me.lblSettlement_Amount.BackColor = lngYellow
    Me.lblSettlement_Amount = "Check Value Under $10"

    Else
    
    DoCmd.CancelEvent
    
    
    Exit Sub
    
    End If

Other info - users cannot edit field, it is locked.

I am hoping for a miracle because I need to have this issue solved and working by morning. Any help is appreciated. I am going to do some other work for a while, so if you stuble onto this, I would love the help.

Thanks,

misscrf

It is never too late to become what you could have been ~ George Eliot
 
nevermind, I got it...

Had to change the currency data type to integer, declare integer variable, and the > should have been a < . now it works!

Code:
Private Sub Form_Current()


Dim lngRed As Long
Dim lngBlack As Long
Dim lngYellow As Long
Dim myamount As Integer
Dim lngWhite As Long

lngWhite = RGB(255, 255, 255)
lngRed = RGB(255, 0, 0)
lngBlack = RGB(139, 137, 137)
lngYellow = RGB(255, 255, 0)
myamount = Me.Amount

'Stop

If myamount < 10 Then
    
    Me.Amount.BackColor = lngYellow
    Me.lblAmount.BackColor = lngYellow
    Me.lblAmount.Caption = "Under $10"

Else

Me.Amount.BackColor = lngWhite
Me.lblAmount.Caption = "Amount"
  
    End If
     Exit Sub
End Sub

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top