Select Case - What am I doing wrong?

G

Guest

I have the following code in the after update event of QuanToOrder.
It's supposed to give a message box that says Can't order blah blah blah if
you try to order more than you have set for the ideal quantity and do nothing
if it is = or less than... but it is showing the message box regardless of
whether the strTotalQuan is less than, equal to, or greater than the ideal
quantity.
What am I doing wrong????

Dim strTotalQuan As String
strTotalQuan = "[QuanOnHand]+[QuanToOrder]"

Select Case Me.IdealQuant
Case Is > strTotalQuan
MsgBox "You Can't Order More Than Your Preset Ideal Quantity.
Please change " & _
"your quantity to order.", vbOKOnly, "Ideal Quantity"
Cancel = True
Case Else
End Select
 
K

Katrina

Do you have actual quotations in this statement? If so take them out.

strTotalQuan = "[QuanOnHand]+[QuanToOrder]"

HTH
Katrina
 
G

Guest

When I do that I get the error message:
Can't find the field "l" referred to in your expression


Katrina said:
Do you have actual quotations in this statement? If so take them out.

strTotalQuan = "[QuanOnHand]+[QuanToOrder]"

HTH
Katrina
kinlye said:
I have the following code in the after update event of QuanToOrder.
It's supposed to give a message box that says Can't order blah blah blah if
you try to order more than you have set for the ideal quantity and do nothing
if it is = or less than... but it is showing the message box regardless of
whether the strTotalQuan is less than, equal to, or greater than the ideal
quantity.
What am I doing wrong????

Dim strTotalQuan As String
strTotalQuan = "[QuanOnHand]+[QuanToOrder]"

Select Case Me.IdealQuant
Case Is > strTotalQuan
MsgBox "You Can't Order More Than Your Preset Ideal Quantity.
Please change " & _
"your quantity to order.", vbOKOnly, "Ideal Quantity"
Cancel = True
Case Else
End Select
 
R

Ron2006

As Katrina says, as you have your code now
the string field of strTotalQuan will contain the following literal

"[QuanOnHand]+[QuanToOrder]"

It is not containing the sum of those two fields but the letters
between the two "s above.

It would seem that that total quantity field should be an integer at
the least depending on how bit the two parts can be.


Ron
 
G

Guest

Okay... had a moment....
The error was because the second one should be Quantity, not QuanToOrder.
But it still gives the same message box regardless whether it's above below
or equal to the Ideal Quantity. Like it isn't checking for cases, just
giving the message box. Any ideas?

Thanks for your quick responses.
 
G

Guest

I did change the str to int and String to Integer and that fixed it!!
Thank you for your help with this.
:)

kinlye said:
Okay... had a moment....
The error was because the second one should be Quantity, not QuanToOrder.
But it still gives the same message box regardless whether it's above below
or equal to the Ideal Quantity. Like it isn't checking for cases, just
giving the message box. Any ideas?

Thanks for your quick responses.

Ron2006 said:
As Katrina says, as you have your code now
the string field of strTotalQuan will contain the following literal

"[QuanOnHand]+[QuanToOrder]"

It is not containing the sum of those two fields but the letters
between the two "s above.

It would seem that that total quantity field should be an integer at
the least depending on how bit the two parts can be.


Ron
 
D

David F Cox

I do not really believe you want [QuanOnHand]+[QuanToOrder] to be a string
variable.
 
D

David F Cox

What I am doing wrong is looking at this group with the wrong sort order,
and not seeing previous replies. Sorry all.

David F Cox said:
I do not really believe you want [QuanOnHand]+[QuanToOrder] to be a string
variable.


kinlye said:
I have the following code in the after update event of QuanToOrder.
It's supposed to give a message box that says Can't order blah blah blah
if
you try to order more than you have set for the ideal quantity and do
nothing
if it is = or less than... but it is showing the message box regardless
of
whether the strTotalQuan is less than, equal to, or greater than the
ideal
quantity.
What am I doing wrong????

Dim strTotalQuan As String
strTotalQuan = "[QuanOnHand]+[QuanToOrder]"

Select Case Me.IdealQuant
Case Is > strTotalQuan
MsgBox "You Can't Order More Than Your Preset Ideal Quantity.
Please change " & _
"your quantity to order.", vbOKOnly, "Ideal Quantity"
Cancel = True
Case Else
End Select
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top