473,394 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Stock levels

53
hello I am currently working on a project for college, based on a shop and have created querues which allow me to total up new customer orders
however i am currently sruggling on how to create a system which will update the stock level one a customer pruchases an item in the product table, and then a warning message should appear when the stock reaches the re order level
do i create a new query for this or use the following below
below are my tables
Customer
Customer Order
Customer Order Details
Products -- includes fileds "Product ID", "Qty_in_Stock", "Re_Order_level" and "Need re ordering" the need re ordering is yes/ no format
Suppliers

here are the queries i have created


"All customer order details" (this includes Product ID, Qty_on_Order, and product name) here is where orders are made and where line totals are added.

so i want ot be able to link the fields to make the field Qty_in_Stock go down automatically after an order and once the Re_Order_level is met for the field Need re ordering to be ticked.
i would be grateful for any help what soever and wil be really thankful!
Jan 30 '07 #1
37 3829
NeoPa
32,556 Expert Mod 16PB
Basically, you need a form on which you would enter the orders (including all the details). This form would arrange to update the Products.Qty_in_Stock whenever an order is created or modified in the form for the relevant product. It could also update Products.[Need re ordering] if required.
If you are designing a system like this, I would consider reading this link (Normalisation and Table structures) first. Products.[Need re ordering] should probably not be held as stored data.
Jan 30 '07 #2
panjap
53
Basically, you need a form on which you would enter the orders (including all the details). This form would arrange to update the Products.Qty_in_Stock whenever an order is created or modified in the form for the relevant product. It could also update Products.[Need re ordering] if required.
If you are designing a system like this, I would consider reading this link (Normalisation and Table structures) first. Products.[Need re ordering] should probably not be held as stored data.
thank you for your help but oi am sorry i do not understand what you mean, i have read the normalisation, and feel i have carried this out, however, in my query customer making order (e.g. where line total * qty), do i then add the field qty in stock and apply some sort of formula
i would really be appreciative of your help as i am really stcuk by this problem
thank you
Jan 30 '07 #3
NeoPa
32,556 Expert Mod 16PB
Reading that is a good first step.
Be aware :- I am not about to design or implement the whole project for you. That said I think I can still help, but you need to make the journey with me at least.
For updating the [Qty_in_Stock] field (Let's be consistent in our references or we'll certainly get more confused than we need) I suggest that the form gets bound to an updatable query linking the [Customer Order] & [Customer Order Details] tables. When you update or add an Order line, then you would need to have some code in your SubForm's AfterUpdate event that updates the [Products] table depending on the new value and, if updated, the old value as well.

If you don't understand any of this (and as you are a student), I suggest that you take this with your current understanding to your tutor and get him to explain the basic concepts we'll be dealing with. If you're doing this project at school or college then you should be expected to be able to handle it. If not, my doing it for you will not help you to learn anything. My helping you to do it, on the other hand, is another matter ;)
Jan 30 '07 #4
maxamis4
295 Expert 100+
I too was once a student and saw how diffcult things were. I am also not going to create your project for you but here is a tip.

Create a table that you might call par. For each item give it a unique id, a description, the par, and the cost of the item.
Expand|Select|Wrap|Line Numbers
  1.  
  2. TBL_PAR
  3. UID PK
  4. DESCRIPTION
  5. PAR
  6. COST
  7.  
  8.  
Your second table should be called sales. This is where you track customer purchase history. The table should include something like so;

Expand|Select|Wrap|Line Numbers
  1. TBL_SALES
  2. QUANTITY (HOW MANY WERE SOLD)
  3. ITEM FK (FORIEGN KEY) = UID
  4. DOS (DATE OF SALE)
  5. CUSID (IF YOU HAVE A CUSTOMER UNIQUIE ID REFERENCE HERE)
  6.  
  7.  
  8.  
With an update query you could have the par subtract the quantity of the sale.

good luck and let me know if you need any more help
Jan 30 '07 #5
NeoPa
32,556 Expert Mod 16PB
Nice one Maxamis.
It's always nice to see a Junior Member contributing to others' threads.
Jan 30 '07 #6
panjap
53
I too was once a student and saw how diffcult things were. I am also not going to create your project for you but here is a tip.

Create a table that you might call par. For each item give it a unique id, a description, the par, and the cost of the item.
Expand|Select|Wrap|Line Numbers
  1.  
  2. TBL_PAR
  3. UID PK
  4. DESCRIPTION
  5. PAR
  6. COST
  7.  
  8.  
Your second table should be called sales. This is where you track customer purchase history. The table should include something like so;

Expand|Select|Wrap|Line Numbers
  1. TBL_SALES
  2. QUANTITY (HOW MANY WERE SOLD)
  3. ITEM FK (FORIEGN KEY) = UID
  4. DOS (DATE OF SALE)
  5. CUSID (IF YOU HAVE A CUSTOMER UNIQUIE ID REFERENCE HERE)
  6.  
  7.  
  8.  
With an update query you could have the par subtract the quantity of the sale.

good luck and let me know if you need any more help

cheers for your help in a new query (sotck level query) I have added up the total products sold for all orders taken palce by adding up the Qty_on_Order. this gave me the new automatic field SumOfQty_on_Order
i then have the field Qty_in_Stock in the products table and in a new query i have attempted this formula

New_Level: Sum([Products].Qty_in_Stock-([stock level Query].[SumOfQty_on_Order]

but says error message of error in parenthesis oreither bracket and vertical bar

i also tried
New_Level: Sum[Qty_in_Stock]-[SumOFQTY_on_Order]

but failed again. i would be most grateful for any tips and thank you for both your help earlier on.
i decided to leave date out of this at the moment could that be a problem?
Thank you
Jan 30 '07 #7
MMcCarthy
14,534 Expert Mod 8TB
cheers for your help in a new query (sotck level query) I have added up the total products sold for all orders taken palce by adding up the Qty_on_Order. this gave me the new automatic field SumOfQty_on_Order
i then have the field Qty_in_Stock in the products table and in a new query i have attempted this formula

New_Level: Sum([Products].Qty_in_Stock-([stock level Query].[SumOfQty_on_Order]

but says error message of error in parenthesis oreither bracket and vertical bar

i also tried
New_Level: Sum[Qty_in_Stock]-[SumOFQTY_on_Order]

but failed again. i would be most grateful for any tips and thank you for both your help earlier on.
i decided to leave date out of this at the moment could that be a problem?
Thank you
You're not closing your parentheses ..

Expand|Select|Wrap|Line Numbers
  1.  
  2. New_Level: Sum([Products].[Qty_in_Stock]-[stock level Query].[SumOfQty_on_Order])
This will sum [Qty_in_Stock] less the [SumOfQty_on_Order] for each [Qty_in_Stock] value

However if you are trying to sum the quantity in stock and then remove the total quantity on order you will need the following.

Expand|Select|Wrap|Line Numbers
  1.  
  2. New_Level: Sum([Products].[Qty_in_Stock])-[stock level Query].[SumOfQty_on_Order]
  3.  
Jan 31 '07 #8
panjap
53
You're not closing your parentheses ..

Expand|Select|Wrap|Line Numbers
  1.  
  2. New_Level: Sum([Products].[Qty_in_Stock]-[stock level Query].[SumOfQty_on_Order])
This will sum [Qty_in_Stock] less the [SumOfQty_on_Order] for each [Qty_in_Stock] value

However if you are trying to sum the quantity in stock and then remove the total quantity on order you will need the following.

Expand|Select|Wrap|Line Numbers
  1.  
  2. New_Level: Sum([Products].[Qty_in_Stock])-[stock level Query].[SumOfQty_on_Order]
  3.  
thankyou for all your help but for some rason after tyoing in the sepcified query this error message came uo

You tried to execute a query that does not include the specified expression <name> as part of an aggregate function.
hane you any ideas on why this happens. i do noy see any problem with your code. IS it my Query set up?
thankyou again for your help
Jan 31 '07 #9
MMcCarthy
14,534 Expert Mod 8TB
thankyou for all your help but for some rason after tyoing in the sepcified query this error message came uo

You tried to execute a query that does not include the specified expression <name> as part of an aggregate function.
hane you any ideas on why this happens. i do noy see any problem with your code. IS it my Query set up?
thankyou again for your help
Yes the problem is in the query. Can you change the query view to sql and copy and paste the full query in here.

Mary
Jan 31 '07 #10
panjap
53
Yes the problem is in the query. Can you change the query view to sql and copy and paste the full query in here.

Mary
here is is below
thankyou so much


SELECT [All customer order details].Prod_ID, Products.Prod_Name, [stock level Query].SumOfQty_on_Order, Products.Qty_in_Stock, Sum([Products].[Qty_in_Stock])-[stock level Query].[SumOfQty_on_Order] AS ew_Level
FROM (Products INNER JOIN [All customer order details] ON Products.Prod_ID = [All customer order details].Prod_ID) INNER JOIN [stock level Query] ON Products.Prod_ID = [stock level Query].Prod_ID
GROUP BY [All customer order details].Prod_ID, Products.Prod_Name, [stock level Query].SumOfQty_on_Order, Products.Qty_in_Stock, Sum([Products].[Qty_in_Stock])-[stock level Query].[SumOfQty_on_Order];
Jan 31 '07 #11
MMcCarthy
14,534 Expert Mod 8TB
Try this ...

Expand|Select|Wrap|Line Numbers
  1. SELECT [All customer order details].Prod_ID, Products.Prod_Name, 
  2. [stock level Query].SumOfQty_on_Order, Products.Qty_in_Stock, 
  3. Sum([Products].[Qty_in_Stock])-[stock level Query].[SumOfQty_on_Order] AS ew_Level
  4. FROM (Products INNER JOIN [All customer order details] 
  5. ON Products.Prod_ID = [All customer order details].Prod_ID) 
  6. INNER JOIN [stock level Query] 
  7. ON Products.Prod_ID = [stock level Query].Prod_ID
  8. GROUP BY [All customer order details].Prod_ID, 
  9. Products.Prod_Name, [stock level Query].SumOfQty_on_Order,
  10. Products.Qty_in_Stock;
Jan 31 '07 #12
panjap
53
Try this ...

Expand|Select|Wrap|Line Numbers
  1. SELECT [All customer order details].Prod_ID, Products.Prod_Name, 
  2. [stock level Query].SumOfQty_on_Order, Products.Qty_in_Stock, 
  3. Sum([Products].[Qty_in_Stock])-[stock level Query].[SumOfQty_on_Order] AS ew_Level
  4. FROM (Products INNER JOIN [All customer order details] 
  5. ON Products.Prod_ID = [All customer order details].Prod_ID) 
  6. INNER JOIN [stock level Query] 
  7. ON Products.Prod_ID = [stock level Query].Prod_ID
  8. GROUP BY [All customer order details].Prod_ID, 
  9. Products.Prod_Name, [stock level Query].SumOfQty_on_Order,
  10. Products.Qty_in_Stock;

thanyou again for all your help
this woiurks except for some products whhich come out with unusual results

here are the results

Expand|Select|Wrap|Line Numbers
  1. SumOfQty_on_Order       Qty_in_Stock     New level
  2. 19                       60               401
  3. 23                       60               397  
  4. 22                       60               398
  5. 2                        60                58
  6. 2                        60                58  
  7. 7                        60                73
  8. 3                        60                57

what could be the problem?
Jan 31 '07 #13
MMcCarthy
14,534 Expert Mod 8TB
Try this ...

Expand|Select|Wrap|Line Numbers
  1. SELECT [All customer order details].Prod_ID, Products.Prod_Name, 
  2. [stock level Query].SumOfQty_on_Order As QtyOnOrder, Sum(Products.Qty_in_Stock) As QtyInStock, 
  3. QtyInStock-[stock level Query].[SumOfQty_on_Order] AS New_Level
  4. FROM (Products INNER JOIN [All customer order details] 
  5. ON Products.Prod_ID = [All customer order details].Prod_ID) 
  6. INNER JOIN [stock level Query] 
  7. ON Products.Prod_ID = [stock level Query].Prod_ID
  8. GROUP BY [All customer order details].Prod_ID, 
  9. Products.Prod_Name, [stock level Query].SumOfQty_on_Order;
Jan 31 '07 #14
panjap
53
thanyou again for all your help
this woiurks except for some products whhich come out with unusual results

here are the results

SumOfQty_on_Order Qty_in_Stock New level
19 60 401
23 60 397
22 60 398
2 60 58
2 60 58
7 60 73
3 60 57


what could be the problem?

[Hello here are the new results

Qty_in_Stock - 60 for all

SumOfQty_on_Order
19
23
22
2
2
7
3
the ORIGINAL "Qty_in_Stock" were all 60


"ewlevel" (calculated field)
401
397
398
58
58
73
57

what could be the problem?
Jan 31 '07 #15
MMcCarthy
14,534 Expert Mod 8TB
[Hello here are the new results

Qty_in_Stock - 60 for all

SumOfQty_on_Order
19
23
22
2
2
7
3
the ORIGINAL "Qty_in_Stock" were all 60


"ewlevel" (calculated field)
401
397
398
58
58
73
57

what could be the problem?
Copy and paste the last query I gave you in exactly.

Mary
Jan 31 '07 #16
NeoPa
32,556 Expert Mod 16PB
This isn't really a progression as such. I just thought re-presenting the SQL may help to spot any potential problems.
Expand|Select|Wrap|Line Numbers
  1. SELECT A.Prod_ID,P.Prod_Name,
  2.        S.SumOfQty_on_Order As QtyOnOrder,
  3.        Sum(P.Qty_in_Stock) As QtyInStock,
  4.        [QtyInStock]-[QtyOnOrder] AS New_Level
  5. FROM (Products AS P
  6.     INNER JOIN [All customer order details] AS A
  7.     ON P.Prod_ID=A.Prod_ID)
  8.     INNER JOIN [stock level Query] AS S
  9.     ON P.Prod_ID = S.Prod_ID
  10. GROUP BY A.Prod_ID,P.Prod_Name,
  11.          S.SumOfQty_on_Order;
Jan 31 '07 #17
panjap
53
Try this ...

Expand|Select|Wrap|Line Numbers
  1. SELECT [All customer order details].Prod_ID, Products.Prod_Name, 
  2. [stock level Query].SumOfQty_on_Order As QtyOnOrder, Sum(Products.Qty_in_Stock) As QtyInStock, 
  3. QtyInStock-[stock level Query].[SumOfQty_on_Order] AS New_Level
  4. FROM (Products INNER JOIN [All customer order details] 
  5. ON Products.Prod_ID = [All customer order details].Prod_ID) 
  6. INNER JOIN [stock level Query] 
  7. ON Products.Prod_ID = [stock level Query].Prod_ID
  8. GROUP BY [All customer order details].Prod_ID, 
  9. Products.Prod_Name, [stock level Query].SumOfQty_on_Order;
sorry this did not work as the
this worked however this alterd the Qtyinstock of the product 1, 2 and 3 to "420" and product 6 to "180". and still carried out the correct calculations
Jan 31 '07 #18
panjap
53
all the other products worked fine
Jan 31 '07 #19
NeoPa
32,556 Expert Mod 16PB
sorry this did not work as the
this worked however this alterd the Qtyinstock of the product 1, 2 and 3 to "420" and product 6 to "180". and still carried out the correct calculations
Can you explain this?
I'm not sure what you're trying to say here.
Jan 31 '07 #20
panjap
53
Can you explain this?
I'm not sure what you're trying to say here.
for all the qty in stock i entered 60, and this came up in the query forr all prodcuts except
for the product ID 1, and product id 2 and 3
here for some reason thi came up as the reading 420.
While for product id 7 this came up as 180

and then it carried out the normal function of qty in stock - qty on order
Jan 31 '07 #21
MMcCarthy
14,534 Expert Mod 8TB
sorry this did not work as the
this worked however this alterd the Qtyinstock of the product 1, 2 and 3 to "420" and product 6 to "180". and still carried out the correct calculations
OK there are two things going on here. You can't represent the Qty_In_Stock as an individual figure and a sum of Qty_In_Stock in the calculated field at the same time. So I've changed the Qty_In_Stock to only represent the total sum figure required for the calculation.
Jan 31 '07 #22
panjap
53
OK there are two things going on here. You can't represent the Qty_In_Stock as an individual figure and a sum of Qty_In_Stock in the calculated field at the same time. So I've changed the Qty_In_Stock to only represent the total sum figure required for the calculation.

do i now need to chane the query, sorry i do not follow you
Jan 31 '07 #23
MMcCarthy
14,534 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2. [All customer order details].Prod_ID, 
  3. Products.Prod_Name, 
  4. [stock level Query].SumOfQty_on_Order As QtyOnOrder, Sum(Products.Qty_in_Stock) As QtyInStock, 
  5. (QtyInStock-QtyOnOrder) AS New_Level
  6. FROM (Products INNER JOIN [All customer order details] 
  7. ON Products.Prod_ID = [All customer order details].Prod_ID) 
  8. INNER JOIN [stock level Query] 
  9. ON Products.Prod_ID = [stock level Query].Prod_ID
  10. GROUP BY [All customer order details].Prod_ID, 
  11. Products.Prod_Name, [stock level Query].SumOfQty_on_Order;
  12.  
This query will represent each product and the total qty of that product on order, the qty of the product in stock and the new balance of qty in stock.

There must be more than one customer order of a product in this query if it's multiplying the qty on order figure.

Mary
Jan 31 '07 #24
panjap
53
Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2. [All customer order details].Prod_ID, 
  3. Products.Prod_Name, 
  4. [stock level Query].SumOfQty_on_Order As QtyOnOrder, Sum(Products.Qty_in_Stock) As QtyInStock, 
  5. (QtyInStock-QtyOnOrder) AS New_Level
  6. FROM (Products INNER JOIN [All customer order details] 
  7. ON Products.Prod_ID = [All customer order details].Prod_ID) 
  8. INNER JOIN [stock level Query] 
  9. ON Products.Prod_ID = [stock level Query].Prod_ID
  10. GROUP BY [All customer order details].Prod_ID, 
  11. Products.Prod_Name, [stock level Query].SumOfQty_on_Order;
  12.  
This query will represent each product and the total qty of that product on order, the qty of the product in stock and the new balance of qty in stock.

There must be more than one customer order of a product in this query if it's multiplying the qty on order figure.

Mary

for some reason this still does not work
do you have any ideas
thank sooo much for all your help so far
Feb 1 '07 #25
MMcCarthy
14,534 Expert Mod 8TB
for some reason this still does not work
do you have any ideas
thank sooo much for all your help so far
You will need to give a breakdown of the tables involved, the relevant fields and what they are storing. The relationships between those tables and the subsequent queries that form the basis for this query. Explain again in plain english rather that computer speak exactly what you are trying to do.
Feb 1 '07 #26
panjap
53
You will need to give a breakdown of the tables involved, the relevant fields and what they are storing. The relationships between those tables and the subsequent queries that form the basis for this query. Explain again in plain english rather that computer speak exactly what you are trying to do.

Here is a break down of my original tables

CUSTOMER

Cu ID
And all their personal details such as contact details


CUSTOMER ORDER
This is where the order takes place and contains the following information


Order_ID
Cu_ID
Staff_ID
Order_Date
Required_Date
Recievied_Date
Order_Total
Delivery
Delivery costs
Overall discount
Type-Of_Purchase
Paid
Money_Owed
Final Costs


CUSTOMER ORDER DETAILS
Here is the specific details of one order.

Order_ID
Prod_ID
Qty_on_Order
Discount
Line_Total

PRODUCTS

Prod_ID
Supp_ID
Product_Name
Product_Type
Prod_ Unit_Details
Qty_in_Stock
Re_Order_level
Price
Unit_Cost
Manufacturer_ID
Shelf_Life

SUPPLIER TABLE – with detaisl e.g Supp Id and account number

SUPPLIER ORDER
Supp_OrderID
Supp_ID

Date_Ordered
Date_Required
S_Delivery_Date
S_Order_Total
Money_Owed Delivery
Driver
Supp_Credit_ Limit
Overall discount
VAT
Type-Of_Purchase

S_Paid
Supp_Final_Costs

SUPPLIER ORDER DETAILS

Supp_OrderID
Prod_ID
Qty
Unit_Detials
Qty_Recieved
Discount
Line_Total


QUERIES

• In the query “All customer order details”, I have worked out the line total for each prodcut with in one order. I have timed the Qty_on_Order (customer order details table) by price (in the produt table) and by the discount(customer order details) this then gives the line total
• I then made a new query called “Customer Query making order” where by I added up all the line totals for one orders and called this “Order_Total”, I inserted here the delivery cost (customer order) and overall discount(customer order)
• I than made a new query called “FINAL COSTINGS”, where I the order total was added to the delivery cost and times by the overall discount.

Now to update the stock level I made a new query called “stock level Query”, where I added up the total number of each products sold, by adding the “Qty_on_Order” from the query “All customer order details”

I then made a new query called “stock level 2” where I calculated the amount left on the shelves by taking “SumOfQty_on_Order” of each product, from “Qty_in_Stock” to produce “Qty_in_Stock”









I am trying to produce a system which controls the stock control.
So far the system can add up the total number of products sold, for all the orders, and then automatically calculate the Qty_ in_ stock by taking away the “SumOfQty_on_Order” once a new order is made. This was the initial problem which I have now sorted thanks to all your help.
However I can not make the “Qty_in_Stock”, to appear in the actual table “Products”.
At the moment I can only update this in the query “stock level 2”. I need this as I can then set re order level which then comes up with an error message telling me when the re order level has been reached.

As later on I will need to add on any products brought in from the suppliers to the Qty_in_Stock”, in the products table to be automatically updated.
Feb 2 '07 #27
panjap
53
could this work instead
if i make a new query containing product ID, and name, and also the Re_Order_level, and Qty_in_Stock(updated)
could i then use some formula to work out with a mesage or in another format that the Qty_in_Stock has reached the Re_Order_level, and to warn that it needs reordering.
this could be either a message and/or a filed called 'Need_Reordering' which is then ticked.
also is it possible when putting in a new order to say that there is not enough when over ordering?
thank you for your help
it has been great
Feb 2 '07 #28
MMcCarthy
14,534 Expert Mod 8TB
Now to update the stock level I made a new query called “stock level Query”, where I added up the total number of each products sold, by adding the “Qty_on_Order” from the query “All customer order details”

I then made a new query called “stock level 2” where I calculated the amount left on the shelves by taking “SumOfQty_on_Order” of each product, from “Qty_in_Stock” to produce “Qty_in_Stock”.
Can you post the SQL of the following queries

“stock level Query”
“All customer order details”

Mary
Feb 3 '07 #29
panjap
53
Can you post the SQL of the following queries

“stock level Query”
“All customer order details”

Mary
Here is
“stock level Query”

Expand|Select|Wrap|Line Numbers
  1. SELECT [All customer order details].Prod_ID,
  2.        Sum([All customer order details].Qty_on_Order) AS SumOfQty_on_Order,
  3.        Products.Prod_Name
  4. FROM Products INNER JOIN [All customer order details]
  5.   ON Products.Prod_ID = [All customer order details].Prod_ID
  6. GROUP BY [All customer order details].Prod_ID,
  7.          Products.Prod_Name;

here is “All customer order details”


Expand|Select|Wrap|Line Numbers
  1. SELECT [Customer Order Details].Prod_ID,
  2.        Products.Price,
  3.        [Customer Order Details].Qty_on_Order,
  4.        [Customer Order Details].Discount,
  5.        (Products.Price*[Qty_on_Order]*(1-[Discount])/100)*100 AS Line_Total,
  6.        [Customer Order Details].Order_ID,
  7.        Products.Prod_Name,
  8.        Products.Prod_Type,
  9.        [Customer Order].Cu_ID
  10. FROM [Customer Order] INNER JOIN
  11.      (Products INNER JOIN
  12.      [Customer Order Details]
  13.      ON Products.Prod_ID=[Customer Order Details].Prod_ID)
  14.      ON [Customer Order].Order_ID=[Customer Order Details].Order_ID
  15. ORDER BY [Customer Order Details].Order_ID;

and here is
Feb 3 '07 #30
NeoPa
32,556 Expert Mod 16PB
It seems to me, that you don't want to store this value at all.
If you store it you will need to implement all sorts of checks and code to make sure that it is maintained accurately and stays in step with the related data (orders; purchases etc).
Whereas, if you calculate it on the fly (as you already know how to do), then it will always be accurate automatically and will also save you the extra head-ache of maintaining the data.
To better understand this concept have a look through Normalisation and Table structures which explains it quite well.
Feb 3 '07 #31
nico5038
3,080 Expert 2GB
Have to point to NeoPa's normalization, as that's the way to go.
I've developed such a system and used a table with purchases and a table with supplier deliveries to calculatethe stock. I just worked on a yearly basis and started the year with a dummy supplier record holding the start values of the stock for that year.

Nic;o)
Feb 3 '07 #32
panjap
53
i have now been able to work out how to work out the quantity left in the stock after taking it away from the new qty in stock in a query called stock level 3.
there are the fields

Prod_ID (Products)
Prod_Name (Products)
SumOfQty_on_Order (from "stock level Query")
Qty_in_Stock: Products.Qty_in_Stock-[SumOFQTY_on_Order]
Re_Order_level (Products)

However i a have been really struggling on how to make the database to tell me i am ordering mre stock then there is.
how can i now when i make sure when i place a new order in the query"All customer order details" , that if i order above the number of "Qty_in_Stock" (from query srock level 3), that i am unable to do this an error message appears

here are both sql form both tables

All customer order details

SELECT [Customer Order Details].Prod_ID, Products.Price, [Customer Order Details].Qty_on_Order, [Customer Order Details].Discount, (Products.Price*[Qty_on_Order]*(1-[Discount])/100)*100 AS Line_Total, [Customer Order Details].Order_ID, Products.Prod_Name, Products.Prod_Type, [Customer Order].Cu_ID
FROM [Customer Order] INNER JOIN (Products INNER JOIN [Customer Order Details] ON Products.Prod_ID=[Customer Order Details].Prod_ID) ON [Customer Order].Order_ID=[Customer Order Details].Order_ID
ORDER BY [Customer Order Details].Order_ID;



stock level 3

SELECT [All customer order details].Prod_ID, Products.Prod_Name, [stock level Query].SumOfQty_on_Order, Products.Qty_in_Stock-[SumOFQTY_on_Order] AS Qty_in_Stock, Products.Re_Order_level
FROM (Products INNER JOIN [All customer order details] ON Products.Prod_ID = [All customer order details].Prod_ID) INNER JOIN [stock level Query] ON Products.Prod_ID = [stock level Query].Prod_ID
GROUP BY [All customer order details].Prod_ID, Products.Prod_Name, [stock level Query].SumOfQty_on_Order, Products.Qty_in_Stock-[SumOFQTY_on_Order], Products.Re_Order_level;


I would be greatful for any help, as i am really stuggling
Thank you
Feb 3 '07 #33
NeoPa
32,556 Expert Mod 16PB
I can't help you with this any more I'm afraid.
You may want to consider following the guidelines about posting if you want the other experts to help (POSTING GUIDELINES: Please read carefully before posting to a forum).
I tried adding code tags to your post again, only to find the lines were way to long to be read.
In case you're not aware, SQL is not affected by line breaks, so can quite easily be posted on here in a readable format, simply by breaking the lines.
Feb 4 '07 #34
panjap
53
have now been able to work out how to work out the quantity left in the stock after taking it away from the new qty in stock in a query called stock level 3.
there are the fields

Expand|Select|Wrap|Line Numbers
  1. Prod_ID (Products)
  2. Prod_Name (Products)
  3. SumOfQty_on_Order (from "stock level Query")
  4. Qty_in_Stock: Products.Qty_in_Stock-[SumOFQTY_on_Order]
  5. Re_Order_level (Products)
However i a have been really struggling on how to make
the database to tell me i am ordering mre stock then there is.
how can i now when i make sure when i place a new order in the query"All customer order details" , that if i order above the number of "Qty_in_Stock" (from query srock level 3), that i am unable to do this an error message appears

here are both sql form both tables

All customer order details

Expand|Select|Wrap|Line Numbers
  1. SELECT [Customer Order Details].Prod_ID,
  2.   Products.Price,
  3.   [Customer Order Details].Qty_on_Order,
  4.   [Customer Order Details].Discount,
  5.   (Products.Price*[Qty_on_Order]*
  6.   (1-[Discount])/100)*100 AS Line_Total,
  7.   [Customer Order Details].Order_ID,
  8.   Products.Prod_Name,
  9.   Products.Prod_Type,
  10.   [Customer Order].Cu_ID
  11. FROM [Customer Order] INNER JOIN 
  12.   (Products INNER JOIN [Customer Order Details]
  13.   ON Products.Prod_ID=[Customer Order Details].Prod_ID)
  14.   ON [Customer Order].Order_ID=[Customer Order Details].Order_ID
  15. ORDER BY [Customer Order Details].Order_ID;


stock level 3

Expand|Select|Wrap|Line Numbers
  1. SELECT [All customer order details].Prod_ID, 
  2.   Products.Prod_Name, [stock level Query].
  3.   SumOfQty_on_Order,
  4.   Products.Qty_in_Stock-[SumOFQTY_on_Order] AS Qty_in_Stock,
  5.   Products.Re_Order_level,Products.Prod_Name,
  6.   [stock level Query].
  7. FROM (Products INNER JOIN [All customer order details]
  8.   ON Products.Prod_ID = [All customer order details].Prod_ID)
  9.   INNER JOIN [stock level Query]
  10.   ON Products.Prod_ID = [stock level Query].Prod_ID
  11. GROUP BY [All customer order details].Prod_ID,
  12.   SumOfQty_on_Order,
  13.   Products.Qty_in_Stock-[SumOFQTY_on_Order],
  14.   Products.Re_Order_level;
Feb 5 '07 #35
NeoPa
32,556 Expert Mod 16PB
Although you made an effort to follow the posting instructions (well done - I'm happy with that), I tidied them up a little further and added the code tags (That's the most important bit btw - Select code to surround in Tags and click on the control marked with the # character when posting).
After doing that, I can see that there is an error in the SQL you posted on the sixth line of your last (Stock Level 3) query. You have no field specified but just a queryname with a trailing (.).

BTW I should just clarify what I said about SQL not being effected by Line Breaks. This is true only where white space is expected. In other words, anywhere you can put a space you can put a line break; a tab or multiples of any mixture of these characters.
Feb 5 '07 #36
panjap
53
Although you made an effort to follow the posting instructions (well done - I'm happy with that), I tidied them up a little further and added the code tags (That's the most important bit btw - Select code to surround in Tags and click on the control marked with the # character when posting).
After doing that, I can see that there is an error in the SQL you posted on the sixth line of your last (Stock Level 3) query. You have no field specified but just a queryname with a trailing (.).

BTW I should just clarify what I said about SQL not being effected by Line Breaks. This is true only where white space is expected. In other words, anywhere you can put a space you can put a line break; a tab or multiples of any mixture of these characters.
the code is slightly different
the query for stock level 3 is

Expand|Select|Wrap|Line Numbers
  1. SELECT [All customer order details].Prod_ID,
  2.        Products.Prod_Name,
  3.        [stock level Query].SumOfQty_on_Order,
  4.        Products.Qty_in_Stock-[SumOFQTY_on_Order] AS [New Qty_in_Stock],
  5.        Products.Re_Order_level
  6. FROM (Products INNER JOIN [All customer order details]
  7.   ON Products.Prod_ID = [All customer order details].Prod_ID)
  8.      INNER JOIN [stock level Query]
  9.   ON Products.Prod_ID = [stock level Query].Prod_ID
  10. GROUP BY [All customer order details].Prod_ID,
  11.          Products.Prod_Name,
  12.          [stock level Query].SumOfQty_on_Order,
  13.          Products.Qty_in_Stock-[SumOFQTY_on_Order],
  14.          Products.Re_Order_level;
i do not know whether this would work or not -
if i inserted vaslidation within the form, so that the qty on order is less then or equal to the qty in stock
have you any advice
thank you so much for your help.
Feb 7 '07 #37
NeoPa
32,556 Expert Mod 16PB
To be honest, I cannot, after 38 posts, understand the whole of this thread and answer general questions like (Will this work?)
The idea is to ask manageable questions rather than try to get a whole project sorted out for you. I still find I'm running around after you, adding code tags and tidying up your posts so that they can be read. I don't want to spend even more time, on top of this, rereading all the posts to understand what you're trying to ask me.
It is down to you to ask your question in such a way that it is understandable and of limited scope.

In as much as I have checked over the query, it should work, but could probably be better written as :
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT [All customer order details].Prod_ID,
  2.        Products.Prod_Name,
  3.        [stock level Query].SumOfQty_on_Order,
  4.        Products.Qty_in_Stock-[SumOFQTY_on_Order] AS [New Qty_in_Stock],
  5.        Products.Re_Order_level
  6. FROM (Products INNER JOIN [All customer order details]
  7.   ON Products.Prod_ID = [All customer order details].Prod_ID)
  8.      INNER JOIN [stock level Query]
  9.   ON Products.Prod_ID = [stock level Query].Prod_ID;
I say this because, although it was GROUPing, there were no aggregate functions used and it seemed it was merely an attempt to lose the duplicates (which DISTINCT does better anyway).
Feb 8 '07 #38

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Marion Slaughter | last post by:
----FA48570F00BB51C Content-Type: text/html; charset="iso-35B2-E" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head>...
7
by: simon | last post by:
Hi I know this has been done to death....but obviously at some point in the dim and distant past! I wish to program a retail database for my shop, I have trawled many forums and I only manage...
9
by: simon.harris | last post by:
I have a 'master' stock list with current stock levels (integer) and another table that contains transactions (i.e. item#, #items added/ removed, date, user etc). What I need is an update query...
1
by: savvy | last post by:
I am developing a Garments shopping cart. On the single product page where the customer selects size and colour of a garment and if its ok for him, then adds to his basket, so every time he checks...
3
by: ollyno1uk | last post by:
Hi there I have a table in MySQL database on my web server that contains stock levels amongst other things. twice a day I get emailed an updated stock list in CSV format. What I need is to...
1
by: baker951 | last post by:
I have a problem that some companies in my supplier table deliver on more than one day in a week, is it possible to add more than one value to a single field or do i need seperate fields. Also i...
1
by: asmusdk | last post by:
I am working on creating a stock management database for a small company. The company receives the merchandise from a handful of suppliers and stocks it before it is sent to the customers –...
1
by: compwizard | last post by:
Hello, Would anyone know how to update stock levels? for example for an hire system If hireitem1 ixs selected with amount of 10 and the current stock level is 20 This would leave 10 remaining...
40
by: sazd1 | last post by:
Hi Student2 I am working on similar kind of thing for stock calculation but could not find any solution to my problem even after putting my problem to different forums. I saw your post that you...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.