Comparing Field Values

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

OK, I'm totally stumped with this. I need to compare the value of two
controls so that I can pop up the appropriate message in the AfterUpdate
event of Control1 and they are both numbers:

If Me.Control1 > Me.Control2 Then
MsgBox "The number is too large", vbOKOnly
End If

In this case, the message does not popup. However, if I change the operator:

If Me.Control1 < Me.Control2 Then
MsgBox "The number is too large", vbOKOnly
Eng If

The message pops up but actually no comparison was done. The message appears
regardless of the number I enter into Control1. Am I missing something?
Thanks.
ck
 
In which event are you running this code? Are the two controls bound to
fields? If yes, what is the format of those fields? If no, what is the
format of the two controls?

Post the entire procedure's code ...
 
OK, what I've now done is to add a button that performs this function. The
controls are not bound to any fields and their format are "general number":

Private Sub butConfirm_Click()
If Me.numShipQtyTemp > Me.txtPIQty Then
MsgBox "The quantity is greater than what was in the Proforma
Invoice. Please re-enter.", vbOKOnly
numShipQtyTemp.Value = Null
End If

End Sub

Thanks.
ck
 
Thanks Ken for your help. I've managed to resolve this and it was my fault
for not knowing that columns in listboxes/combo boxes are string since
txtPIQty was assigned a value from a listbox.
ck
 
The values in the other columns of combo boxes and list boxes often come
through as text instead of numbers. This is a common issue that one must
watch for. Glad you found it!
 
Back
Top