Link to home
Start Free TrialLog in
Avatar of ouestque
ouestqueFlag for United States of America

asked on

Access:Create a Table Sum of Categories

I have Table1. I need a second table to be generated from this table that will list each distinct category in table1 followed by the total cost in that category. How would I write VB to do this? (See tables below  )

Table1: THIS IS WHAT I HAVE
Field:  Book Categories     Book Purchases
               Fiction                      $30.02
               Fiction                   $10.05
               Romance            $5.00
               Sci-Fi            $15.00
         Technical            $20.00
         Romance            $19.99
         Sci-Fi            $10.99


Table2 : END RESULT I NEED
Field:    Book Categories     Book Purchases
               Fiction                      $40.02
               Sci-Fi            $25.99
               Romance            $24.99
               Technical            $20.00
        
Avatar of Imoutwest
Imoutwest

Just curious here, why?

1. I would recommend not creating your table, but the values change.
2. What you want is already available through grouping and summary on a Report.
3. Also, you could get these totals from a query.

Imoutwest
Sorry, should be:
1. I would recommend not creating your table, BECAUSE the values change.
ASKER CERTIFIED SOLUTION
Avatar of ldunscombe
ldunscombe
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ouestque

ASKER

Thanks guys! I got how to make the table, but how do I get the total cost to appear in the second column (As described above) Doing it in query form would be fine if you can do it.
SELECT Table1.[Book Categories], Sum(Table1.[Book Purchases]) AS [Total Cost] INTO Table2
FROM Table1
GROUP BY Table1.[Book Categories];

Cheers
Oh yeah sorry idun! you explained that in your earlier post.

Thanks again!!!