I have inherited a old access database that includes a table with data organised like this:
+-------+--------+-------------+-------------+-------------+----------------+
| Code | Year | Category1 | Category2 | Category3 | ... etc ... |
+-------+--------+-------------+-------------+-------------+----------------+
| A | 2011 | 1 | 4 | 12 | |
| A | 2012 | 5 | 33 | 24 | |
| B | 2012 | 4 | 11 | 76 | |
+-------+--------+-------------+-------------+-------------+----------------+
I need to change this (the actual table has lots of columns) to the following structure:
+-------+--------+-------------+--------+
| Code | Year | Cat | Value |
+-------+--------+-------------+--------+
| A | 2011 | Category1 | 1 |
| A | 2011 | Category2 | 4 |
| A | 2011 | Category3 | 12 |
| A | 2012 | Category1 | 5 |
| A | 2012 | Category2 | 33 |
| A | 2012 | Category3 | 24 |
| B | 2012 | Category1 | 4 |
| B | 2012 | Category2 | 11 |
| B | 2012 | Category3 | 76 |
+-------+--------+-------------+--------+
Is it possible to do this via some automatic conversion in MS Access (I have version 2010)?
You can use a union query:
You might like to eliminate the reserved word “Year” while you are at it : http://support.microsoft.com/kb/321266
If you have a lot of categories, you can use VBA to make life easier, for example: