Access comparison error

  • Thread starter Thread starter badger
  • Start date Start date
B

badger

I have a simple calculation that is performed on a form
when a button is pressed. Essentially, the value of
List52.Value is compared to the value of List47. Both
values are type long integer, but about every fifth time,
(even if I use the exact same numbers in each combo box
each time!?!) the comparison is made inaccurately, and
(for example) 1000 is declared to be less than 100. I
actually tested this with 1000 and 100, and it randomly
fails the comparison about every fifth time I hit the
button. Any ideas why this would happen?

If List52.Value > List47.Value Then
MsgBox "Cannot add this item. This order is
shipping more than was requested."
List52.Value = 0
List47.Value = 0
End If
 
Have you added a Debug.Print of the values to the code to see what Access
thinks these values are? While theoretically it shouldn't matter, try
assigning the values to variables then do the comparison.

Dim lngList52 As Long, lngList47 As Long
lngList52 = List52.Value
lngList47 = List47.Value
If lngList52 > lngList47 Then
MsgBox "Cannot add this item. This order is
shipping more than was requested."
List52.Value = 0
List47.Value = 0
End If

Are these single column combo boxes? If not, is the Bound Column the visible
column (the column with the number)?
 
Back
Top