Solved

Running subtraction in Access Db

Posted on 2008-10-28
8
957 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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
 

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

809 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