Solved

Running subtraction in Access Db

Posted on 2008-10-28
8
940 Views
Last Modified: 2013-11-29
Hi, all,

I have an inventory database I'm working on, and want to allocate inventory based on ship date.  For example

Part             Date           Qty On Order             Qty On Hand            Adjusted On Hand
ABC           10/30/08               5                                6                              1
DEF           10/30/08               1                                4                              3
ABC           11/5/08                 3                                1                             -2
DEF           11/6/08                 4                                3                             -1

Where the Qty On Hand for oldest shipments is pulling from an adjusted on hand.  I may have been looking at this too long, and staring an easy answer in the face - but right now I'm stumped...

I appreciate (in advance) any help!

Shauna
0
Comment
Question by:orcas828
  • 4
  • 4
8 Comments
 
LVL 11

Expert Comment

by:miqrogroove
ID: 22822738
Hi orcas828, what is the question exactly?  Do you need help designing a new table?
0
 

Author Comment

by:orcas828
ID: 22822808
Hi, migrogroove,

Sorry if my question wasn't clear.

I have two linked tables to csv files:  BalOnHand and Orders.  I want to be able to allocate inventory to the orders (in order of age), and reduce the balance of the item for newer orders down the list.  

So, if order #1 needs to ship 10/30, with part ABC, qty 5, and balance on hand as 6, a new column would show an adjusted balance of 1 for that part.  Then, for order #5 that needs to ship 11/5, for part ABC, qty 4, I'd show a -3 in the adjusted balance.

I'm not sure what I'd need to do to make that happen.

Hopefully, I've explained my question a little better!
0
 

Author Comment

by:orcas828
ID: 22822818
Kinda like a reverse DSUM (only subtracting for each part, instead of adding...)
0
 
LVL 11

Expert Comment

by:miqrogroove
ID: 22822856
Okay so you just need a running sum.  When you say "a new column would show an adjusted balance of 1 for that part" does that mean it must be calculated and stored in a table?  Or do you only need the running sum to appear in a report?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:orcas828
ID: 22822870
At this point, I only need it to show in a report.
0
 
LVL 11

Expert Comment

by:miqrogroove
ID: 22822946
Excellent.  That will give you a lot of flexibility and a simple answer:

Create a report that has the Qty field listed twice.  One of the two instances will become the running sum or balance column.  In the properties for that field, look at the Data tab and you will see a Running Sum property.  Set this property to "Over All" or as appropriate.  This will give you a running sum of that column in the report output.

Depending on the circumstances, you might need a starting quantity or "balance forward" row in the underlying data.  This can be accomplished with a relatively simple union query.
0
 

Author Comment

by:orcas828
ID: 22822967
Will the running sum do a running subtract, though?
0
 
LVL 11

Accepted Solution

by:
miqrogroove earned 500 total points
ID: 22823054
Yes I think one of the nuances here is that you want to display a positive quantity ordered but have a negative running sum.  So for simplicity this report should be based on a query that has the qty ordered column also listed twice.  In the Field row of the query's design view for one of the two columns, enter something like:

QtyChange: -[QtyOrdered]

Now if you set the data source for the 'running sum' field to QtyChange instead of QtyOrdered you will get a negative running sum.

If you are adding to your inventory by receiving shipments then you will want to consider where and how that gets represented.  Ideally you want to end up with a QtyChange column that can make an elegant running sum, even if it is necessary to do a union between orders and receiving.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now