In Access apparently 2 > 10 ????

XV1957

Registered User.
Local time
Today, 15:09
Joined
Aug 6, 2014
Messages
80
Hello Access Experts.
I have an unbound form with a list box, 2 text boxes, and a command button.
As soon as I select a line in the list box, the first text box is being fed the quantity appearing in the second column of the list box. The idea is you can transfer the whole quantity in stock from one warehouse location to another, or a smaller quantity, in which case the user would effectively override the value in the first text box.
I have a few conditions one after the other, so that if the first is not met, the second is tested, etc..
For the life of me, I cannot understand why a condition whereby 2 > 10 would be considered TRUE, but this is the way things are looking. There must be an explanation.

Here is the code:

If Me.txtQty (2 in the example) > Me.lstProducts.Column(1) (10 in the example) Then
MsgBox Me.txtQty & " " & Me.lstProducts.Column(1)
MsgBox "Cannot transfer a quantity GREATER than the quantity in stock"
GoTo exithandler
End If
See the screenshots attached.
Thanks in advance for explaining this apparent mystery. What am I not seeing?:confused:
 

Attachments

  • Capture2.JPG
    Capture2.JPG
    32.9 KB · Views: 97
  • Capture1.JPG
    Capture1.JPG
    26.7 KB · Views: 85
You are dealing with strings, that's why.
You can also tell by the fact that they are left-justified. Numbers are normally bron right-justified.
 
Hi Spikepl,
first of all, thank you very much for your mail.
Sometimes solutions can be simple, and yet we do not see them.
This is the beauty of this forum and the participants like you.
I will correct my code.
Have a nice day.
 

Users who are viewing this thread

Back
Top Bottom