Whats the code to Update current stock level (1 Viewer)

colepale

New member
Local time
Today, 10:40
Joined
Sep 2, 2020
Messages
3
Hello Guys,

Please i would require your assistance on an inventory stock management application i am creating using MS Eexcel and Access.

I would require a VBA code to update current stock level whenever sales is made.

An Example if i have

50 items of Pencils and 30 was sold how do i update my stock level immediately to reflect the balance of 20

I will appreciate a swift response either using MS access or excel
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:40
Joined
May 7, 2009
Messages
19,226
the normal thing is, you Don't save it.
you run a query and perform the arithmetic there:

supposed you have a table (tblTransaction)
ID (autonumber)
TransDate (date)
TransType (short text, "in" or "out") ("in" if you bought it and added to inventory, "out" if you sell it)
ItemCode (short text)
Quantity (Numeric)


to get the Remaining balance of an Item using Query:

SELECT ItemCode, SUM(IIF(TransType="in", Quantity, -Quantity)) As RemainingBalance
FROM tblTransaction
GROUP BY ItemCode
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:40
Joined
Sep 21, 2011
Messages
14,217
I would say that the method would be the same in either app.?
You subtract Out from In?

In Excel, the calculation would likely be immediate. In Access you would run a query/formula to calculate the same way.

You would NOT store the 'balance'
 

colepale

New member
Local time
Today, 10:40
Joined
Sep 2, 2020
Messages
3
the normal thing is, you Don't save it.
you run a query and perform the arithmetic there:

supposed you have a table (tblTransaction)
ID (autonumber)
TransDate (date)
TransType (short text, "in" or "out") ("in" if you bought it and added to inventory, "out" if you sell it)
ItemCode (short text)
Quantity (Numeric)


to get the Remaining balance of an Item using Query:

SELECT ItemCode, SUM(IIF(TransType="in", Quantity, -Quantity)) As RemainingBalance
FROM tblTransaction
GROUP BY ItemCode
Thank you this information was useful
 

colepale

New member
Local time
Today, 10:40
Joined
Sep 2, 2020
Messages
3
I would say that the method would be the same in either app.?
You subtract Out from In?

In Excel, the calculation would likely be immediate. In Access you would run a query/formula to calculate the same way.

You would NOT store the 'balance'
Thank you for your quick response, In excel whats the formular for immediate update on each item?
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:40
Joined
Sep 21, 2011
Messages
14,217
Thank you for your quick response, In excel whats the formular for immediate update on each item?
I would use a SUMIF on each of the items. Outgoings should be be a negative, then just Sum the cells. If you have a separate column for outgoing then subtract that total from the incoming total.

Also try Googling. There must be plenty of links to such workbooks?
 

Users who are viewing this thread

Top Bottom