IIf Statement

P

Pass-the-reality

I have a form called frmBrochures. Within this form, I have 3 fields -
product, max qty and order qty. Product is a drop down (from a table). When
you select the product, the max qty populates. How do I set an alert if the
order qty exceeds the max qty amount? Example -

Product Max Order
Paper 10 20

After keying in 20, I would want a alert that the qty is over the max.
 
W

Wayne-I-M

You could let the user know there is a problem. You have not said if you
will allow the ordering of larger quanities than you have in stock - there
may be a delivery in the morning so you take the order - If not you can
always set the code to delete the quantity amount until it is equall to or
lower the the Max - up to you

Open the form in design view and right click the OrderQnty control
Open the properties box
In the evet column select the AfterUpdate row
Click the build option (...)
Select Code

Put this (change the names of the controls to what you really use)


Private Sub OrderQnty_AfterUpdate()
If Me.OrderQnty > Me.MaxQnty Then
MsgBox "Put some message here", vbQuestion, "There is a problem"
End If
End Sub

Good luck
 
N

NetworkTrade

in the afterupdate event of the order control put:

If me.order>me.max then
MsgBox ("You have exceeded the maximum available.")
me.order=0
end if
 

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

Similar Threads


Top