views:

588

answers:

5

How do I transpose rows and columns in Access 2003? I have a multiple tables that I need to do this on.

(I've reworded my question because feedback tells me it was confusing how I originally stated it.)

Each table has 30 fields and 20 records.
Lets say my fields are Name, Weight, Zip Code, Quality4, Quality5, Quality6 through Quality30 which is favorite movie. Let's say the records each describe a person. The people are Alice, Betty, Chuck, Dave, Edward etc through Tommy..

I can easily make a report like this:

  >>Alice...120....35055---etc, etc, etc...Jaws  
  Betty....125....35212...etc, etc, etc...StarWars  
  etc  
  etc  
  etc  
  Tommy...200...35213...etc, etc, etc...Adaptation

But what I would like to do is transpose those rows and columns so my report displays like this

  >>Alice........Betty......etc,etc,etc...Tommy  
  120.........125........etc, etc, etc...200  
  35055.....35212....etc, etc, etc...35213  
  etc   
  etc  
  etc  
  Jaws...StarWars..etc,etc,etc...Adaptation

Thanks for any help.

+3  A: 

Access actually has a transpose verb, crosstab. You'll find good stuff if you search for "crosstab", which is the more common database-y way to say it. Like this Knowledge Base article. The generic database answers usually involve transpose and summarize. If you need a non-summary crosstab, it can be done, but you'll likely need a custom function.

Henry Troup
Thank you for your response. I think I dont understand though.The Knowledge Base article talks about summarizing but all I want to do is transpose rows-to-columns and columns-to-row. I dont want to summarize. Surely this must be something people do !! Any other ideas? (I dont have the skills to do a customer function.) Thanks.
Lisa Schwaiger
The Crosstab Wizard will walk you through the whole process.
Robert Harvey
Thanks for the 2nd response. But I'm afraid I still just dont get it. I searched and read about Crosstab and used the Crosstab wizard and I just simply dont see how on earth to transpose stuff -- change all my rows to columns and all my columns to rows. To rephrase what I am trying to do: I need to display my 30 fields as rows (instead of columns), and my 20 reords as columns (instead of rows). Thanks for helping :)
Lisa Schwaiger
A: 
TRANSFORM SUM(Weight)
SELECT "Dummy Data"
FROM myTable 
GROUP BY "Dummy Data"
PIVOT [Name]

Does this help?

EDIT: This assumes that names won't repeat.
i.e. There will not be more than 1 record for a given Name.

shahkalpesh
Thanks for the reply. I have lots and lots more fields/columns than just Name and Weight, and lots more records/rows. (I have 20+ unique names.) I just tried to keep my example very simple. How would I word your query if I had Field1 through Field30 and 20 unique names instead of just fields Weight and Age. To rephrase, all I am trying to do is transpose, i.e., for my report, turn my 30 columns into 30 rows and turn my 20 rows into 30 columns. Thanks for helping.
Lisa Schwaiger
I mean turn my 20 rows into 20 columns
Lisa Schwaiger
shahkalpesh
Thanks for your help; I appreciate it. I have reworded what I'm trying to do.
Lisa Schwaiger
A: 

Thanks to all for your help.
I believe I have discovered the answer, and I put the link to it here in case someone else needs it in the future: http://support.microsoft.com/kb/202176
(This works for Access 2003.)

Lisa Schwaiger
Which of the two approaches outlined there did you choose?
David-W-Fenton
A: 

Do it in Excel if you're more comfortable there

Export back to Access when you're done

George
A: 

i have same problem at end , i Export table to Excel And do the transpose , Impart again but i still believe it must be anther way without going out of access 2003

Michel GB