Solved

Access - A query needed to keep inventory based on Sales

Posted on 2007-04-07
5
251 Views
Last Modified: 2010-03-20
I can't seem to get this done, am frustrated as heck and would appreciate help...

I have two Access tables that I'm trying to query to get a running inventory and a quick glance of how much has been made on each against the cost of the items.

Table 1 - Named: Inventory
        Fields wanted: ITEMNBR (the Item Number), COST (My Cost) CQTY (How many I have in Stock)

Table 2 - Named: Sales
        Fields wanted: ItemID (the Item Number), Quantity (the quantity sold), PriceEa (price each the customer paid),                          TotalPrice (Quantity x PriceEa)

I want this:

ITEMNBR COST CQTY InStock(Inventory.CQTY - Sales.Quantity), SalesTotal (Sales.PriceEa x Sales.Quantity)


Now, here's the kicker. the Sales.PriceEa is not always the same for each item. And I have multiple lines for items in Inventory.ITEMNBR because my cost changes with each order that I make.

So, here's an example of my Sales Table:

ItemID      PriceEa      
AC2001       2.50
AC2001  0.75
AC2001  3.60

An Example of my Inventory Table:

ITEMNBR      Cost      CQTY
AC2001      1.50      2
AC2001      2.75      2

So I need Access to count the first two sales against the first AC2001 in the table and then, because that one is now out of stock, move to the second AC2001 and count the third sale again that.

I'd like it to look like this:

ITEMNBR      Cost      InStock      SalesTotal
AC2001      1.50      0      3.25
AC2001      2.75      1      3.60

I hope that this makes sense and is possible...

Thanks in advance for your help.
0
Comment
Question by:Mada123
  • 2
5 Comments
 
LVL 37

Accepted Solution

by:
momi_sabag earned 500 total points
Comment Utility
hi

in order to achive what you want, you will have to provide some column that will allow to sort the rows
there is no way you can tell which ac2001 item was sold first and which was sold second if you don't have such a column, and it will be impossible to solve your problem
0
 

Author Comment

by:Mada123
Comment Utility
I'm all for sorting rows and adding columns... I will change whatever is necessary to accomplish this. But I don't know what needs to be done. Can you please assist? Thanks much!
0
 
LVL 37

Expert Comment

by:momi_sabag
Comment Utility
i guess the easiest thing to do would be to add a timestamp column (that is date+time)
that will hold for each row the date and time of the insert statement
that way you can keep track of which items were up to sell in every point in time
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 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

12 Experts available now in Live!

Get 1:1 Help Now