Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Desperate - Need to turn columns into rows

Posted on 2011-05-13
3
Medium Priority
?
279 Views
Last Modified: 2012-05-11
I have 2 Microsoft Access databases.  One table has a users information and another has survey questions and their answers.  I need to get the user info and that person's answers into a row.

The tables look like this:

FirstName LastName Address        SurveyNumber  
Joe            Smith      Maple Street    1                        
Juan           Gonzalez  First Street     2


SurveyNumber     Question   Answer
1                        Height         6 foot
1                        Weight        250
2                        Height         6 foot 1

What query and/or report can I write to make it look like this:

FirstName     LastName   Height    Weight                    
Joe               Smith          6 foot      250
Juan             Gonzalez     6 foot 1  

Thank you very much in advance
0
Comment
Question by:Mikek5665
3 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 35754039
select U.FirstName, U.LastName, H.Answer, W.Answer
from UserInfo U
join Survey H
  on H.SurveyNumber = U.SurveyNumber
 and H.Question = 'Height'
join Survey W
  on W.SurveyNumber = U.SurveyNumber
 and W.Question = 'Weight'
0
 
LVL 77

Accepted Solution

by:
peter57r earned 2000 total points
ID: 35754047
You need to create a standrad query joining the two tables on SurveyNumber- output all fields.

Save this query (as say 'qry1')

Then use the crosstab query wizard to build your desired result from this saved query.  The Name fields go into rows, the Question field into columns and the answer into the summary, choosing the 'First' option for the summary.
0
 

Author Closing Comment

by:Mikek5665
ID: 35755728
Thank you so much.  The delay in accepting the answer was because I had to get the work done and out the door first.  Yay!!!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question