Solved

Running subtraction in Access Db

Posted on 2008-10-28
8
972 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

830 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