AVForums

Our philosophy in our forums, reviews, podcasts and feature videos is to promote audio and visual excellence by gathering and sharing the best information and resources available.

Help

To begin please visit our help section »

Not a Member Yet?

It only takes a minute to start enjoying the benefits of AVForums membership, and it's free!

Member Log in

Is anyone a demon in MS Access?

Post Reply
Old 14-07-2009, 9:41 AM   #1
Prominent Member
 
Shoka's Avatar
Join Date: Jan 2002
Location: Surrey
Experience Points:
12,203, Level: 26
Points: 12,203, Level: 26 Points: 12,203, Level: 26 Points: 12,203, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Thanks: Gave 305, Got 246
Posts: 4,336
Is anyone a demon in MS Access?

I'm trying to manipulate some data at work but cannot manage to achieve what I want to do.

I have several records which contain the same(ish) data for example:

ProductQTYPrice
Milk2£0.50
Milk1£0.25
Bread1£0.50
Bread3£1.50

What I want to achieve is a new table with just 1 record per product but with the QTY and Price for the matching records summed.

Is it possible?
  Quote
Old 14-07-2009, 9:58 AM   #2
Member
Join Date: Sep 2006
Location: Leeds
Experience Points:
2,880, Level: 12
Points: 2,880, Level: 12 Points: 2,880, Level: 12 Points: 2,880, Level: 12
Activity: 0.4%
Activity: 0.4% Activity: 0.4% Activity: 0.4%
Thanks: Gave 41, Got 63
Posts: 558
Re: Is anyone a demon in MS Access?

Im guessing you want to group the same product names together and total the quantity and price fields, you can do that in a query like:

SELECT Product, Sum(Qty) AS TotalQty, Sum(Price) AS TotalPrice FROM <TableName> GROUP BY Product;

...or another way of getting the same output would be to...
Go to the query sidetab click New
Add the table to the query
Click "Totals" (on the iconbar, its the Sigma button)
You then get an extra row (called "total") at the bottom
Double-click the Product field, Qty field and Price field so they appear at the bottom
They should all have a "total" calue of "Group By". Leave that for Product (as youre grouping by product code), change "total" for Qty and Price fields to "Sum" (add grouped items together).

You can then click "View" to see the contents of the query, or change it to a Make Table query to make a new table. I recommend saving this as a query as it will change with the products table, it helps you to keep your data in sync and will behave just like a table for most things you want to do with it (except you cant edit it).

Hope this helps,
Jas.
  Quote
Thanks from:
Shoka (14-07-2009)
Old 14-07-2009, 10:14 AM   #3
Prominent Member
 
Shoka's Avatar
Join Date: Jan 2002
Location: Surrey
Experience Points:
12,203, Level: 26
Points: 12,203, Level: 26 Points: 12,203, Level: 26 Points: 12,203, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Thanks: Gave 305, Got 246
Posts: 4,336
Re: Is anyone a demon in MS Access?

Quote:
Originally Posted by jasonf01 View Post
Im guessing you want to group the same product names together and total the quantity and price fields, you can do that in a query like:

SELECT Product, Sum(Qty) AS TotalQty, Sum(Price) AS TotalPrice FROM <TableName> GROUP BY Product;

...or another way of getting the same output would be to...
Go to the query sidetab click New
Add the table to the query
Click "Totals" (on the iconbar, its the Sigma button)
You then get an extra row (called "total") at the bottom
Double-click the Product field, Qty field and Price field so they appear at the bottom
They should all have a "total" calue of "Group By". Leave that for Product (as youre grouping by product code), change "total" for Qty and Price fields to "Sum" (add grouped items together).

You can then click "View" to see the contents of the query, or change it to a Make Table query to make a new table. I recommend saving this as a query as it will change with the products table, it helps you to keep your data in sync and will behave just like a table for most things you want to do with it (except you cant edit it).

Hope this helps,
Jas.
You are a legend - thanks a tonne! works perfectly and achieved exactly what I wanted to do.
  Quote
Old 14-07-2009, 11:46 AM   #4
Member
Join Date: Sep 2006
Location: Leeds
Experience Points:
2,880, Level: 12
Points: 2,880, Level: 12 Points: 2,880, Level: 12 Points: 2,880, Level: 12
Activity: 0.4%
Activity: 0.4% Activity: 0.4% Activity: 0.4%
Thanks: Gave 41, Got 63
Posts: 558
Re: Is anyone a demon in MS Access?

Youre welcome, glad it worked for you.

On a side note, if anyone in Yorkshire is looking for an innovative developer with 18+ years of varied experience in software, hardware and interfaces, feel free to drop me a PM.

(shameless plug!)

Jas.
  Quote
Post Reply



Thread information and display options
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off