Access Subtracting an amount with a confim box

  • Thread starter Thread starter DualFever
  • Start date Start date
D

DualFever

Hello i am trying to create a workshop program, it needs to keep all the
stock and once a part or tyre is fitted take it out of the stock.

So far so good, but i've got to a problem where i must subtract an amount
from a cell in a table called 'stocklist' to take away stock when its been
used, what code would i use to take away an amount in a text box(called
'quantitytxt') from a cell in a table the table is called 'stocklist' the
column called 'quantity' and it has to be the cell down where the coloumn
'part' is what the user has selected.

So some type of code like:

Dim bresult
bresult=MsgBox( "Stock","are you sure you want to remove " & quantitytxt & "
from " & parttxt "'s stock.", vbYesNo)
If bresult = True then
'now im not quite sure here how this works
stocklist.quantity - quantitytxt WHERE part = parttxt
EndIf

Or if theres a easier way through a macro or expression builder let me know
please , i hope you understand what im trying to achieve thanks for any help!
 
You cannot just subtract a value like that and expect the database to give
you accurate info. Too many things can go wrong here, and the quantities
gradually become more and more wrong as time goes on.

For example, someone means to type that 4 tyres were used, but they actually
typed 44 by mistake. Your code subtracts 44 tyres from inventory. After that
happens, they go back and change it to 4. Your program now subtracts
*another* 4, so 48 have now been subtracted.

Or, they choose the wrong tyre, so 4 of the wrong thing we subtracted. They
go back and change it to the correct type, but did you add the other 4 back
in again?

The solution is to get Access to calculate the stock for you when needed.
For an example, see:
Inventory Control - Quantity On Hand
at:
http://allenbrowne.com/AppInventory.html
 
Hi
I did have thoughts about the user typing in the wrong amount or other
problems occuring, thats one reason for the confirmation box, thanks for the
resource it looks like that would be the best way of doing it, im not that
familiar with everything i see on that page, but i'l try that technique.

A good idea would be a downloadable sample project on your pages like this! :)

Thanks again

-Dual
 
Back
Top