Solved

Access - A query needed to keep inventory based on Sales

Posted on 2007-04-07
5
252 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
ID: 18871931
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
ID: 18872286
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
ID: 18872306
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 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

13 Experts available now in Live!

Get 1:1 Help Now