comparing 2 variables

ianclegg

Registered User.
Local time
Today, 07:07
Joined
Jul 14, 2001
Messages
58
Hi

Am I missing something?

I am trying to compare a field of which it should fall between 2 values which are LW_Less 5 and LW_Plus5 if the comparison falls between these 2 values it should turn the background colour of the box green. This condition is never met and the box always turns red.

I would be grateful for any help in resoving my problem

I have listed my code below.

Regards

Ian Clegg



Private Sub CalcPlusandMinus()
CalcWeight = CalculatedWeight

LW_Less5 = (LoadWeight / 100 * 95)
LW_Plus5 = (LoadWeight / 100 * 105)

If CalculatedWeight >= "' & LW_Less5 & '" And CalculatedWeight <= "' & LW_Plus5 &'" Then

MsgBox "True"
marker = "green"
CalculatedWeight.BackColor = 65280 'Green
Else
CalculatedWeight.BackColor = 255 'Red
marker = "red"

Me.Repaint
End If

End Sub
 
Howzit

Try this

Code:
Private Sub CalcPlusandMinus()
CalcWeight = CalculatedWeight

LW_Less5 = (LoadWeight / 100 * 95)
LW_Plus5 = (LoadWeight / 100 * 105)

If CalculatedWeight >= LW_Less5 And CalculatedWeight <= LW_Plus5 Then

MsgBox "True"
marker = "green"
CalculatedWeight.BackColor = 65280 'Green
Else
CalculatedWeight.BackColor = 255 'Red
marker = "red"

Me.Repaint
End If

End Sub
 
Cracked it, Thanks very much for your help

Regards
 

Users who are viewing this thread

Back
Top Bottom