update Using values from a form

L

Lerato

I have 2 tables, stock and transactions. i want to subtract the value antered
on the form from the UnitsInStock value on the stock table.
how do i get the value from the form.
Currently my query reads;
UPDATE Stock SET UnitsInStock = UnitsInStock-Forms!FrmTransactions!NumOfUnits
WHERE ProductName=forms!FrmTransactions!ProdName;
 
S

Steve

You could create a query that included both your stock and transactions
tables where the query included the field UnitsInStock. You could lock the
UnitsInStock field to prevent data entry or you could make the field not
visible on your form. Then you could put the following code in the Form's
AfterUpdate event;
Me!UnitsInStock = Me!UnitsInStock - Me!NumOfUnits

You put the code in the form's AfterUpdate event so Me!UnitsInStock would
not get changed until you go to a new record or close the form. That way if
an error is made entering NumOfUnits, you can go back and correct the error
without immediately changing UnitsInStock.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 

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

Top