While im not new to databases, i am out of practice and was wondering how to create a total price attribute for a store database.
The table has the attributes: PT KEy, Product ID, Quantity, offer, Total item price(the product table has the prices, this field is just the price multiplied by the quantity), offer.
I am trying to make a field that adds up all the Total item prices in the table, giving the entire price of the transaction.
Should i make this field in another table or do it in the current one? if so how?
So in the end i made it a calculated field in that was generated in a query. I removed any calculated fields of the such and replaced them in the queries.
Related
So, lets say I have 3 tables.
First table is the product table where it consists of
Prod_code, Prod_name, Prod_qty, Prod_Price1, Prod_Price2.
The second table is the Order table where it consists of
Order_ID, Order_Date, Total_price.
And the last table is the order detail table which consists of
Order_Detail_ID, Order_ID (foreign key from order table), Prod_code(foreign key from Product table), Qty_Ordered, and Price
If you can see I have 2 prices for each product in the product table for the purpose of:
If the Qty_ordered from the order detail table is greater than 10 unit, then the Price column in the order detail given will be Prod_price2
If the Qty_ordered from the order detail table is equal to or less than 10 unit, then Price column in the order detail given will be Prod_price1
How can I make this happen so when I create an order detail form, it can automatically give me the Product price based on the Qty_ordered that I input?
I believe this could require some if statements in the query but I'm a novice in Ms. Access and I need you guys' help. Thanks a lot
In a query that joins Orders and Products to OrderDetails, calculate a field with:
IIf(Qty_Ordered <= 10, Prod_Price1, Prod_Price2)
If you need to display this on data entry form bound to OrderDetails, build a combobox that lists products and has both prices as columns (can be hidden if you want). An expression in textbox can reference columns of combobox by their index. So if Price1 is in third column its index is 2.
=IIf(Qty_Ordered <= 10, Me.cbxProduct.Column(2), Me.cbxProduct.Column(3))
Saving this calculated result will require code (macro or VBA) in some event, probably form BeforeUpdate.
Me!Price = Me.tbxPrice
Table1 feildes
Product{ID,Product,Quantity(in peices),Cost(per peice)}
table2
Customer{ID, Name, Type(local,sale's man)}
table 3
customer order{ID, date,customer*, product*,quntity,price}
here customer is coming from table 2 named as customer while product is coming from table1 named as products
i just want to show remaining items in order table. any can help me to make this happen?enter image description here
You mean you want to know how much of each product remains after filling orders? This is calculating inventory balance - a common topic. You need a table that records receipt of product, which is apparently your Products table but I think would be better titled ProductReceived. Do an aggregate query on ProductReceived and an aggregate query on Orders then do another query that joins the two and subtracts the latter from the former. Customer table not needed for this. Products table would just be a lookup table for product info - no Quantity or Cost fields as these belong in ProductReceived. Products table should have the selling price you want to charge.
You have misspelled 'piece' in your field names.
Advise no spaces, punctuation, or special characters in field names (underscore is only exception). Better would be Qty_Pieces.
I got a table StockMovements which records all movements of my
products. It has a field named "Status", which can have either the
value Sold or Purchased, Quantity and Product (there are few more but
arent important now).
I made a query to take all the products with the status "Purchased"
and to take the quantity and named it Purchased Products (From the
table StockMovements). I have just sum the quantity and got the
purchased quantity for the each product (named the field Purchased).
I made another query, all the same just with the Status of Sold.
After I made a new query with the name Stock. Its built of the table
Products and the 2 queries I mentioned above. It takes the prodict_ID
and the product name from the table Product, the purchased field from
the first query and the Sold field from the second query and then a
final field not connected to any of above but a calculation. Named it
AvailableQuantity and added next with expression builder to it
=[Purchased] - [Sold].
Now when I run the query it works fine, except one thing. When I have
a specific quantity of a purchased product which I havent sold to
anyone yet (not even 1 piece) it doesnt want to show up in the query.
I want the product to show in the query and that the available
quantity is the purchased quantity. So somehow to skip the Sold value
if its 0 and just to write the Purchased quantity to that field.
When you have no sold qty your sum effectively becomes Purchased-Null which will result in no answer.
You should allow for nulls by using [Purchased] - (Nz([Sold],0)) which will force a zero into the calculation.
I went into the SQL view and changed the INNER JOIN to RIGHT JOIN, it did the job.
SELECT tblProduct.Product_ID, tblProduct.ProductName, Nz([Purchased],0) AS
PurchasedQuantity, Nz([Sold],0) AS SoldQuantity, [PurchasedQuantity]-(Nz([SoldQuantity],0))
AS [Available] FROM qrySoldProducts RIGHT JOIN (qryPurchasedProducts RIGHT JOIN
tblProduct ON qryPurchasedProducts.Product_ID = tblProduct.Product_ID) ON
qrySoldProducts.Product_ID = tblProduct.Product_ID;
I have three tables: product, sales_order (where I sell products) and purchase_order (where I buy products). Now I can think of two ways of keeping the quantity of each product:
Have a column in the product table called quantity; when inserting into sales_order, I subtract the quantity; when inserting into purchase_order, I add the quantity
Instead of storing the quantity in the product table, I calculate the quantity from the sales_order and the purchase_order table each time I need to get the product table
I am wondering if the second approach is preferable to the first one? I like the second one more because it doesn't store any redundant data; however, I am not so sure if calculating the quantity every time is a bit too much calculation. I am wondering what is the convention and best practice here? Thank you!
I would use the first one. Add a column to the product table in the coding u code -x amount when order and you would then display this in the order table. You could right a script for when the products get to a certain amount it emails you and tells u to replenish stocks. However the second would also work and sql is very powerful so i wouldnt wprry about it being ro demanding as it will prbably work it out faster than we can lol
I prefer the first one because in-memory calculations are faster than issuing select statements to check the sales orders and purchase orders assuming that the number of times the quantity value is retrieved is significantly more than the number of times the quantity value is updated.
Good afternoon all,
I am in the process of creating a database in which I want to enter a product name and a dose and a price will be returned. I have created two tables (tbllog and tblcosting). The tblcosting contains the products along with all the available doses and the prices they cost. Is there a way of inputting the product and dose onto one form and having a box that returns the price based on these two criteria?
Any advice you could pass on would be very much appreciated.
Select product from a combobox. Make the combobox RowSource multi-column:
SELECT ProductID, ProductName, Dose, Cost FROM tblCosting ORDER BY ProductName;
Have textboxes reference the combobox columns by index to display the associated info. Index begins with 0 so Cost is in column index 3:
=[cbxProduct].Column(3)