Solved Message box if has decimal

theinviter

Registered User.
Local time
Yesterday, 18:40
Joined
Aug 14, 2014
Messages
251
Dears;
I Have Created a form where the user enter the quantity to request in Pcs. as i want after entering the value do a calculation by divide the Number on MOQ. and if there decimal number then show a message box and cancel and if the result without decimal them accept it.
can you guide me please:
Private Sub QTY_BeforeUpdate(Cancel As Integer)
If QTY / [Min OQ] = 1 Then
MsgBox " Please coorect the Quantity"

Else


End if

thanks
 
Please help me understand.

What is MOQ? Does that represent Minimum Order Quantity? Is that an accurate guess?

Do you only allow orders that are exact multiples of the MOQ? OR
Do you only allow orders that are exactly the MOQ?

Please provide an example, using numbers, to illustrate the requirement.
I suspect that there is at least one approach that will work here, but it's a lot easier when the requirement is clear.
 
Please help me understand.

What is MOQ? Does that represent Minimum Order Quantity? Is that an accurate guess?

Do you only allow orders that are exact multiples of the MOQ? OR
Do you only allow orders that are exactly the MOQ?

Please provide an example, using numbers, to illustrate the requirement.
I suspect that there is at least one approach that will work here, but it's a lot easier when the requirement is clear.
yes it is,
example
Qnty = 24 but MOQ (Min OQ) = 21 . so 24 / 21 = 1.14 . which is not accepted, as i want the use to adjust the quantity to get zero decimal.
 
yes it is,
example
Qnty = 24 but MOQ (Min OQ) = 21 . so 24 / 21 = 1.14 . which is not accepted, as i want the use to adjust the quantity to get zero decimal.
In other words, people can only order the exact minimum order quantity? No more and no less?
Why let them enter anything at all?

I'm still trying to figure out the business rule being applied....
 
I agree with George. What exactly is the business rule regarding Order Quantity?
For example:
If MOQ is 20 for Product X and I want to purchase 40,then that's OK.(Since it is a multiple of MOQ)
But, if there is an Order quantity for a non-integer multiple of MOQ, then that triggers a message.
Right?
 
Perhaps the problem is this:

You accept only 1 as a valid answer, therefore, the ONLY possible value for Quantity Ordered is the same as the MOQ. Anything else, even the example Jack provided, results in a value different from 1. It returns 2, which has no decimal, but is also not equal to 1.

Therefore, assuming he's right (which I think is the case), then the calculation needs to use a different math operator.
 
If you have different, fixed packages such as 6-pack, case(12), single, then you might want to have different SKUs and then change your data type for quantity to be an integer. So you order 1 6-pack or 1 case. or 13 singles or 1 case and 1 single.
 
I agree with George. What exactly is the business rule regarding Order Quantity?
For example:
If MOQ is 20 for Product X and I want to purchase 40,then that's OK.(Since it is a multiple of MOQ)
But, if there is an Order quantity for a non-integer multiple of MOQ, then that triggers a message.
Right?
yes you are right. this what i mean.
 
Take a look at the solution in Northwind and see if it makes sense to you.
 
actually the MOQ if fixed for every product.
as the user can request any quantity with multiple of MOQ, for example if MOQ is 20 then can accept 20, 40 ,60 or any number multiply of MOQ without decimal.
like if 15 , 25 , or 35 will not accept .
so i tried below code;
Dim D11 As String
D11 = QTY / [Min OQ]


If D11 - Int(D11) <> 0 Then
MsgBox "PLease coorect the number to match packing factor "
Else

End If
 
actually the MOQ if fixed for every product.
as the user can request any quantity with multiple of MOQ, for example if MOQ is 20 then can accept 20, 40 ,60 or any number multiply of MOQ without decimal.
like if 15 , 25 , or 35 will not accept .
so i tried below code;
Dim D11 As String
D11 = QTY / [Min OQ]


If D11 - Int(D11) <> 0 Then
MsgBox "PLease coorect the number to match packing factor "
Else

End If
Okay, that's what we all guessed.

There are other division operators, in addition to the standard /

One of them will provide the exact solution you need.

Someone will no doubt offer it to you, but I think it might be worthwhile to do a little study on your own, as a learning exercise that will pay off in the future.


Focus on the various Arithmetic operators listed and explained
 
Okay, that's what we all guessed.

There are other division operators, in addition to the standard /

One of them will provide the exact solution you need.

Someone will no doubt offer it to you, but I think it might be worthwhile to do a little study on your own, as a learning exercise that will pay off in the future.


Focus on the various Arithmetic operators listed and explained
 

Users who are viewing this thread

Back
Top Bottom