How to put up Message Box when field value is more than another field value

noobmaster

New member
Local time
Yesterday, 23:26
Joined
Sep 2, 2019
Messages
5
I am having an inventory with two fields, ProductQty which is the quantity of product I have at hand and MinimumStk which is the minimum quantity required for the product.

I have already made a query and a report for when MinimumStk > ProductQty, but I was wondering if I can make a Message Box appear when this occurs in the front page of my form.

So far, I have tried

If "ProductQty"< "MinimumStk" Then
MsgBox "There are low stocks"
Else
MsgBox "There are no low stocks"
End If
End Sub

However, it seems like it is only able to do it correctly for my first product and not all my product in the field.

How can I go about achieving a MsgBox when my MinimumStk is more than my ProductQty?
 
I have already made a query and a report for when MinimumStk > ProductQty
assuming that works, you would just change > for <. But this would never work

If "ProductQty"< "MinimumStk" Then
because you are comparing two strings. Remove the double quotes.
 
add code to Form's Load event:
Code:
Private Form_Load()
If Nz(DCount("1"," "yourQueryName", "[ProductQty] < [MinimumStk]"), 0) > 0 Then
MsgBox "There are low stocks"
Else
MsgBox "There are no low stocks"
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom