Solved

Running subtraction in Access Db

Posted on 2008-10-28
8
1,019 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

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)

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

617 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