Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Mychael14 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    11

    Student Scores display in multiple columns

    Hi everyone could you please help me with this. I'm really new in Access and I'm trying to learn it by my self.
    My first question is, how can I display the scores of a student in horizontal? (Bad english)
    I have two tables, one with students information and another for students' score.
    When I query may table using this

    Code:
    SELECT Student.StudentName, WrittenScores.Score
    FROM Student INNER JOIN WrittenScores ON Student.[ID] = WrittenScores.[StudentID];
    It resulted to this


    Click image for larger version. 

Name:	Capture.PNG 
Views:	14 
Size:	8.6 KB 
ID:	20617

    All I want to do is something like this
    Click image for larger version. 

Name:	1.PNG 
Views:	13 
Size:	3.0 KB 
ID:	20618



  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    you need to use a crosstab query, but you will need an additional column for the column header

    you would set
    studentname>group by, row heading
    someothercolumn>group by, column heading
    score>sum or first depending on someothercolumn>value

    someothercolumn might be a testid or date for example


    Alternatively look at using a pivot query, but you will still need a minimum of three columns - column, value and the rest as rows

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Build a Crosstab query.

  4. #4
    Mychael14 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    11

    Thanks

    Quote Originally Posted by ranman256 View Post
    Build a Crosstab query.
    Thanks for your reply... I'll search google for that or maybe you can teach how to do that

  5. #5
    Mychael14 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    11
    Thank you ranman256 and ajax I was able to solve the problem with your help. Can you pls help me again... this time I have three tables similar to my first question, I want to achieve something like this but using CrossTab does not allow me. It needs one ColumnHeading and value option. Thank you very much.
    Click image for larger version. 

Name:	3.PNG 
Views:	13 
Size:	5.0 KB 
ID:	20621

  6. #6
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    you have to create separate crosstabs for each table. Then create a 4th table or query which lists all the names.

    Then in a 5th query, left join this fourth table to the three crosstabs on name. You need a left join in case you have names in table1 which are not in the other tables, similarly for tables 2 and 3.

  7. #7
    Mychael14 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    11
    Hi Ajax, I merge all crosstabs using this query
    Code:
    Select * 
    FROM Query1,QUERY2,QUERY3
    WHERE QUERY1.STUDENTNAME = QUERY2.STUDENTNAME AND QUERY1.STUDENTNAME = QUERY3.STUDENTNAME
    This resulted to this
    Click image for larger version. 

Name:	6.PNG 
Views:	13 
Size:	10.1 KB 
ID:	20622

  8. #8
    Mychael14 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    11
    I'm tired. How can I remove the other columns for name?

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Don't use the * wildcard for all tables, explicitly reference fields in the SELECT clause.

    SELECT Query1.*, Query2.1, Query2.2, Query2.3, Query3.1, Query3.2, Query3.3

    Should probably use JOIN clause instead of the WHERE. Join Query2 and Query3 to Query1.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    Mychael14 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    11
    Hi June7, but Query1 and Query2 is from a table with no definite number of rows. When I query those table I may have more than 3 columns. What can you say?

  11. #11
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    when you use a crosstab as a part of a new query, the crosstab runs before you can view in the new query, so you will know exactly what columns you have

    On the other hand, in each crosstab you can set the column headings - if not already visible, view properties - column headings would then be

    1,2,3

  12. #12
    Mychael14 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    11
    I have to explain my self

    I have three tables holding the scores/marks of students and users may add several quizzes, if they do, this will increasing the number of rows in my 3 tables that will increase the number of columns in crosstab. Then I want to join the queries to have a complete view of the scores of each student.
    Attached Thumbnails Attached Thumbnails Capture.PNG  

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    So you are doing 3 crosstabs on the 3 score tables - join those 3 crosstabs to the Student table. Set each join so that will "Include all records from Student and only those from ..."

    Yes, crosstabs are dynamic for the columns. Review: http://allenbrowne.com/ser-67.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    Mychael14 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    11
    Quote Originally Posted by June7 View Post
    So you are doing 3 crosstabs on the 3 score tables - join those 3 crosstabs to the Student table. Set each join so that will "Include all records from Student and only those from ..."

    Yes, crosstabs are dynamic for the columns. Review: http://allenbrowne.com/ser-67.html
    But what if a user add more quizzes? Let say students have 4 quizzes in WrittenWorks (the Query1), therefore I will have 4 columns for scores in CrossTab. But the query below will show only 3 columns for WrittenScores.

    Code:
    SELECT Student.StudentName, Query1.[1], Query1.[2], Query1.[3], Query2.[1], Query2.[2], Query2.[3], Query3.[1]
    FROM ((Student LEFT JOIN Query1 ON STUDENT.STUDENTNAME = QUERY1.STUDENTNAME) LEFT JOIN Query2 ON STUDENT.STUDENTNAME = QUERY2.STUDENTNAME)LEFT JOIN Query3 ON STUDENT.STUDENTNAME = QUERY3.STUDENTNAME;
    Click image for larger version. 

Name:	Capture.PNG 
Views:	12 
Size:	9.9 KB 
ID:	20637

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Will have to adjust the column heads. That's the problem with CROSSTABs. I have never used them as the basis for a report.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 07-21-2014, 08:47 AM
  2. Replies: 2
    Last Post: 02-21-2013, 07:47 AM
  3. Team Db - Multiple Scores Per Athlete Over Multiple Meets...
    By rattler418 in forum Database Design
    Replies: 7
    Last Post: 12-01-2012, 02:36 AM
  4. Display multiple rows into seperate columns
    By levinkev in forum Queries
    Replies: 1
    Last Post: 08-30-2012, 11:02 AM
  5. Replies: 23
    Last Post: 12-06-2011, 09:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums