473,513 Members | 2,469 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating calculations

53 New Member
Hello,
Please may someone help with a problem as i am struggling on using Microsoft Acess to manipulate data and crete a system which creates orders for a shop as part of my project. i really would be grateful for any help what so ever.
i have the tables

Products which include Prod_ID , Prod_Name and then Price

Customer Order Details which include in order, Order_ID, Prod_ID, Qty_on_Order, Discount and then Line_Total

i would like to know how to apply calculations so that I can times the price of a product by the quantity and discount and then get the line total

i then want to know what calcualtions are needed to insert a final overall cost as the table Customer Order has
Order_Total( which adds up the sum of all Line_Total in Order details)
and then adds Delivery Cost, and times byOverall_Discount and then to produce Final Costs

i would really be appreciative if any one could help me. i would also like to know where to place these calculations. do i create a new query or use the existing tables
Jan 19 '07 #1
17 2274
nico5038
3,080 Recognized Expert Specialist
Normally we use an algoritm iin a query for this.
So place both the Product table and Orderline in a query and join them by the ProductID.
Next add a field in the graphical editor like:
TotalPrice: [Qty] * [Price]

For the overall total re-use this query in a groupby query to get the totals per OrderID and/or ProductID.

Getting the idea ?

Nic;o)
Jan 20 '07 #2
panjap
53 New Member
Normally we use an algoritm iin a query for this.
So place both the Product table and Orderline in a query and join them by the ProductID.
Next add a field in the graphical editor like:
TotalPrice: [Qty] * [Price]

For the overall total re-use this query in a groupby query to get the totals per OrderID and/or ProductID.

Getting the idea ?

Nic;o)
i am grateful for your reply. Though unfortunatley do not under stand what you mane,as i do not know what you mean by "algoritm" in a query, and a what a graphical editor is.
i did however make a query but did not knkw how to insert the calculation
Sorry for any trouble caused, and i wouild really be grteful for any assisstance.
Jan 21 '07 #3
nico5038
3,080 Recognized Expert Specialist
An algoritm is the same as a calculation like:
a = b + c
When you start to build a new query Access will show a window with in the upper half the selected table (from the pop-up form that's displayed first) and below that a serie of cells.
The first row will hold the fieldnames and in that first row you can enter a calculation/algoritm like:
Total:[Qty]*[Price]
Both [Qty] and [Price] need to be fields in the table in the upper half.

Just give it a try and let me know the result.

Nic;o)
Jan 21 '07 #4
panjap
53 New Member
An algoritm is the same as a calculation like:
a = b + c
When you start to build a new query Access will show a window with in the upper half the selected table (from the pop-up form that's displayed first) and below that a serie of cells.
The first row will hold the fieldnames and in that first row you can enter a calculation/algoritm like:
Total:[Qty]*[Price]
Both [Qty] and [Price] need to be fields in the table in the upper half.

Just give it a try and let me know the result.

Nic;o)
Hello thank you that is really helpful. the line total worked a treat as a inserted
Line_Total: (Products.Price*[Qty_on_Order]*(1-[Discount])/100)*100
thank you, however i then had another table called customer order.
and here i have the fields

customer ID
Order ID
Order total (this is when all the line totals for one order are added up)
Delivery cost
Overall Discount
Final Costs
i am struggling here to add up the total line order for each order and then add the delivery cost and then any extra discounts to produce final costs.
Please may you help me with this formula as i am really stuck
any help would be much appreciated,
thank you
Jan 21 '07 #5
nico5038
3,080 Recognized Expert Specialist
The delivery cost and then any extra discounts need to be in the Order table and for the Orderdetails you'll now need to create first a groupby query.
Use the created query with the total and place that in the query editor.
Now place the OrderID and the total field.
Next press the "E" looking GroupBy button to get an additional line in the criteria section.
There change the GroupBy under the total field in "Sum".
Save and run this query to see that you get the Order total.

Finally place the Order table and the above GroupBy query in the editor and connect them by the OrderID. Now you can add a calculation like:
TotalOrder:[tblOrder].[DeliveryCost]+[tblOrder].[Discounts]+[qryGroupBy].[SumOfTotal]

Clear ?

Nic;o)
Jan 21 '07 #6
panjap
53 New Member
The delivery cost and then any extra discounts need to be in the Order table and for the Orderdetails you'll now need to create first a groupby query.
Use the created query with the total and place that in the query editor.
Now place the OrderID and the total field.
Next press the "E" looking GroupBy button to get an additional line in the criteria section.
There change the GroupBy under the total field in "Sum".
Save and run this query to see that you get the Order total.

Finally place the Order table and the above GroupBy query in the editor and connect them by the OrderID. Now you can add a calculation like:
TotalOrder:[tblOrder].[DeliveryCost]+[tblOrder].[Discounts]+[qryGroupBy].[SumOfTotal]

Clear ?

Nic;o)
thank you for the information and i sucessfully worked out how to total up the line costs but unfortunatley i am struggling with the final costs. In the same query i typed in
Final_Costs: (Customer Order].[Order_Total]+[Delivery Cost]*(1-[Overall_ Discount])/100)*100
but this did not work. dod you mean i now need to create a new query woth the query i just created with the line totals now added up and with the table customer order. i am vey saoory for your incinvience , and would be very grateful for some help.
Jan 21 '07 #7
nico5038
3,080 Recognized Expert Specialist
Doing fine I see.
Yes, the "tblOrder" and the "GroupBy query" created for the tblOrderDetails need to be combined (placed) into one new query. There you JOIN them by a drag and drop of the OrderID from the table to the query and you should be able to get the final calculation working.

Nic;o)
Jan 21 '07 #8
panjap
53 New Member
Doing fine I see.
Yes, the "tblOrder" and the "GroupBy query" created for the tblOrderDetails need to be combined (placed) into one new query. There you JOIN them by a drag and drop of the OrderID from the table to the query and you should be able to get the final calculation working.

Nic;o)
i am very sorry for troubling you, bu ti have tried again the formula

Final Costs: Sum(([Customer Query making order].Order_Total+[Delivery Cost]*(1-[Overall_Discount])/100)*100)
when creating the query you said, and have inserted relevant fields, however since both are in both tables the error message says the field (Delivery Cost )and other fields coem form both the table and query what suggestion can you pleae offer
i am very soory for troubling you again and i am very thankful for your help
Jan 23 '07 #9
nico5038
3,080 Recognized Expert Specialist
Like the order_total you need to qualify the fields by adding the tablename infront of them like:
Final Costs: Sum(([Customer Query making order].Order_Total+[yoru delivery table].[Delivery Cost]*(1-[yoru delivery table].[Overall_Discount])/100)*100)

Getting the idea ?

Nic;o)
Jan 24 '07 #10
panjap
53 New Member
Like the order_total you need to qualify the fields by adding the tablename infront of them like:
Final Costs: Sum(([Customer Query making order].Order_Total+[yoru delivery table].[Delivery Cost]*(1-[yoru delivery table].[Overall_Discount])/100)*100)

Getting the idea ?

Nic;o)
Hello its me again! thankyou for your help
i entered the formula
Final Costs:Sum(([Customer Query making order].[Order_Total]+[Customer Order].[Delivery Cost]*(1-[Customer Order].[Overall_Discount])/100)*100)

but the result came with a total(also bigger then when i added them all up indvidualy). how do i only get this for one order only.
Also when I tried to enter the customer ID and Order ID
It says “you tried to execute a query that dos not include the specified expression ‘Order_ID’ as part of an aggregate function
please will help resove this problem
Jan 24 '07 #11
nico5038
3,080 Recognized Expert Specialist
Can you use the button top left to switch to SQL mode ?
Copy/paste that here so I can have a look.

The error indecates that the Ordernumber isn't part of a groupby, did you press the "E" looking button ?

Nic;o)
Jan 25 '07 #12
panjap
53 New Member
Can you use the button top left to switch to SQL mode ?
Copy/paste that here so I can have a look.

The error indecates that the Ordernumber isn't part of a groupby, did you press the "E" looking button ?

Nic;o)

here it is form sql

SELECT Sum(([Customer Query making order].[Order_Total]+[Customer Order].[Delivery Cost]*(1-[Customer Order].[Overall_Discount])/100)*100) AS [Final Costs]
FROM [Customer Order] INNER JOIN [Customer Query making order] ON [Customer Order].Order_ID = [Customer Query making order].Order_ID;

also i did not type the "E" looking button for this query but did so only for the query C"ustomer Query making order" to add up all the line totals
thank you for your help!
Jan 25 '07 #13
nico5038
3,080 Recognized Expert Specialist
Try:

SELECT [Customer Order].Order_ID, Sum(([Customer Query making order].[Order_Total]+[Customer Order].[Delivery Cost]*(1-[Customer Order].[Overall_Discount])/100)*100) AS [Final Costs]
FROM [Customer Order] INNER JOIN [Customer Query making order] ON [Customer Order].Order_ID = [Customer Query making order].Order_ID
Group By [Customer Order].Order_ID;

And can you also post the SQL for the [Customer Query making order]

Nic;o)
Jan 25 '07 #14
panjap
53 New Member
Try:

SELECT [Customer Order].Order_ID, Sum(([Customer Query making order].[Order_Total]+[Customer Order].[Delivery Cost]*(1-[Customer Order].[Overall_Discount])/100)*100) AS [Final Costs]
FROM [Customer Order] INNER JOIN [Customer Query making order] ON [Customer Order].Order_ID = [Customer Query making order].Order_ID
Group By [Customer Order].Order_ID;

And can you also post the SQL for the [Customer Query making order]

Nic;o)
thanks fot that
it worked but for some reason the oringinal total order is timsed by 100 and therefore with a total cost of £64 and a delivery of £3 should come to £67 but instead comes £6,403

also the overall discount does not seem to becalculated

What did you mean by "you can also post the SQL for the [Customer Query making order]"
do i need to do this?
thank you for all your help
Jan 25 '07 #15
nico5038
3,080 Recognized Expert Specialist
That will be a bracketing problem, try:

SELECT [Customer Order].Order_ID, Sum([Customer Query making order].[Order_Total]+([Customer Order].[Delivery Cost]*(1-[Customer Order].[Overall_Discount])/100)*100)) AS [Final Costs]
FROM [Customer Order] INNER JOIN [Customer Query making order] ON [Customer Order].Order_ID = [Customer Query making order].Order_ID
Group By [Customer Order].Order_ID;

Nic;o)
Jan 25 '07 #16
panjap
53 New Member
That will be a bracketing problem, try:

SELECT [Customer Order].Order_ID, Sum([Customer Query making order].[Order_Total]+([Customer Order].[Delivery Cost]*(1-[Customer Order].[Overall_Discount])/100)*100)) AS [Final Costs]
FROM [Customer Order] INNER JOIN [Customer Query making order] ON [Customer Order].Order_ID = [Customer Query making order].Order_ID
Group By [Customer Order].Order_ID;

Nic;o)
thankyou this worked
however there was one small problem for the final cost the overall discount applied only to the delivery cost and not the delivery cost and order total added together
here is sql

SELECT [Customer Order].Order_ID, Sum([Customer Query making order].[Order_Total]+([Customer Order].[Delivery Cost]*(1-[Customer Order].[Overall_Discount])/100)*100) AS [Final Costs]
FROM [Customer Order] INNER JOIN [Customer Query making order] ON [Customer Order].Order_ID = [Customer Query making order].Order_ID
GROUP BY [Customer Order].Order_ID;




rcheers for your help
Jan 26 '07 #17
nico5038
3,080 Recognized Expert Specialist
Glad I could help, success with your application !

Nic;o)
Jan 26 '07 #18

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

Similar topics

11
4622
by: lduperval | last post by:
Hi, I`m trying to do date calculations in three types of time zones: local, GMT and specified. The issue I am facing is that I need to be able to specify a date in the proper time zone, and I`m...
3
2565
by: brian kaufmann | last post by:
Hi, I had sent this earlier, and would appreciate any suggestions on this. I need to make calculations for unemployment rate for three different data sources (A,B,C) for many countries and age...
3
2245
by: John M | last post by:
Hi, I've been coming up against a failure of a report to display the result of a simple calculation. I have realised that this calculation cannot take place unless the field I am working on is...
0
1239
by: SJM | last post by:
There is a database which has combo boxes to allow users to select values from pre-set lists of common specifications. The form allows users to enter values that are not in the dropdown lists....
3
1845
by: A.M | last post by:
Hi, Using ASP.NET/VB.NET and SQL Server backend, I need to return calculation results to user as an Access MDB file or Excel XLS sheet. What would be the best way to create a MDB or XLS file...
1
2077
by: john saul | last post by:
Hello All, I am not extremely new to Access but need help to hopefully a simple question. I am creating a project quote form that will ask customers questions and retreive pricing due to the...
2
1693
by: robert.q.johnson | last post by:
Help. I am trying to create a web page in C# to display two rows of data with bar graphs (an image 1px). I get the max value of the row and use the following formula to size the height of the...
1
2393
by: =?Utf-8?B?QXJ0aHVyIFBhcmtlcg==?= | last post by:
I have been looking for information on creating new custom calendars; not the control, but the class that manages dates and date calculations. The only thing I've been able to find in any of the...
9
2604
Catalyst159
by: Catalyst159 | last post by:
I have a form which is used to calculate residential Floor Area Ratio (FAR). The form is structured into seven parts as follows: Part A: Maximum FAR and Floor Area: Part B: Gross Floor Area of...
0
7259
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
7158
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...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5683
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.