Hello All
if I have a query to calculate a quantity on hands from two query as below :
and I have a form that is based on another query, used for making orders. This form includes a combo box for selecting products. I would like to implement a feature where if the quantity of an item is equal to zero, either that item is not shown in the combo box or a warning message appears when the user selects that product.
Regards
how to: show warning when Qty on hand is 0
-
- BronzeLounger
- Posts: 1246
- Joined: 01 May 2016, 09:58
how to: show warning when Qty on hand is 0
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78568
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: how to: show warning when Qty on hand is 0
In the Before Update event of the combo box:
where ComboName is the name of the combo box.
Code: Select all
Private Sub ComboName_BeforeUpdate(Cancel As Integer)
If DLookup("QtyOnHand", "StockQ", "ProductID=" & Me.ComboName) <= 0 Then
MsgBox "This product is out of stock. Please select another one!", vbInformation
Cancel = True
End If
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1246
- Joined: 01 May 2016, 09:58
Re: how to: show warning when Qty on hand is 0
Thank you very much, it worked as usual :)
can we add another line to rest the combo box to " Select a product" when the user click Ok on the message box?
Regards
can we add another line to rest the combo box to " Select a product" when the user click Ok on the message box?
Regards
-
- Administrator
- Posts: 78568
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: how to: show warning when Qty on hand is 0
Unfortunately, you cannot set the value of the combo box in the BeforeUpdate event.
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1246
- Joined: 01 May 2016, 09:58
Re: how to: show warning when Qty on hand is 0
thank you for the information