Quantity field value reduce

meenctg

Learn24bd
Local time
Today, 20:24
Joined
May 8, 2012
Messages
133
I have an simple invoice database. Here i have an Item table in this table has a Stock field.

Other two table
1. InvHdr
2. InvDtls


In InvDtls here a filed quantity

I have used the InvDtls as a subform of InvHdr.
I wanna when i put a quantity in subform for selected Item it will reduce a value from item table from stock field.

A condition will in quantity field
If quantity value > stock value it'll notify that it is not possible.

Please any body help me how to will i do this?
 
After updating the quantity field you could do a check using Dlookup, something like:

If Dlookup("[StockValue]", "nameOfYourItemTableOrQuery", "[StockID]=" & [StockIDNumber]) < QtyValue then
msgbox "You don't have enough stock"
Else
deduct the qty purchased from stock.
end if

You could probably use an update query to update the stock value in the item table, in which case after the Else statement you might have:
docmd.openquery "MyUpdateQuery"

There may be better ways to do it, but hope that helps.
 

Users who are viewing this thread

Back
Top Bottom