Only Allow Record To Be Added If Quantity Greater Than 0?

Napole0n

Registered User.
Local time
Today, 10:23
Joined
Nov 5, 2015
Messages
12
Hello all, I'm currently having a bit of trouble with adding a new order record to my order table only when it makes sense.

I currently have a place order table which can take in an order for a bookshop with either a book on the order, a non book item on the order, or both. The trouble I'm having is that I can add a record which has a book selected but not a quantity, or a non book item but not a quantity, in the example screenshot below:

pGyvcM.png


I could actually hit 'Add New Order' and it would add the record where I would want it to show a pop up box stating that if the Title Of Book or Item field has a value then the quantity field for either must be greater than 0.

Any help would be greatly appreciated.

Thanks in advance.
 
Thank you friend, that seems to have done the trick :)
 
In the forms before update event put

Code:
If Not isNull(Me.[COLOR="DarkRed"]TitleOfBook[/COLOR])  And Me.[COLOR="DarkRed"] QuantityOrdered[/COLOR]  = 0 then
   Msgbox "Quantity Ordered must be greater than zero"
   Cancel = True
   Exit Sub
End IF

If Not isNull(Me[COLOR="darkred"].Item[/COLOR])  And Me.[COLOR="DarkRed"]QuantityOfItem[/COLOR] = 0 then
   MsgBox "Quantity of Item must be greater than zero"
   Cancel = True
   Exit Sub
End IF

Where you would change the names in red to the actual names of the text boxes.
 

Users who are viewing this thread

Back
Top Bottom