Results 1 to 8 of 8
  1. #1
    Jet1234 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2018
    Posts
    4

    Crosstab Query in Report

    Hello,

    I'm new to crosstab queries and simply not getting anywhere on my own. In the attached image, I've been able to get the Red cells working in an Access crosstab query. What I would like shown in the report is the Green cells. Essentially remove any spaces, this would also apply if the student was not taking any courses in a Term.

    Click image for larger version. 

Name:	Capture.JPG 
Views:	15 
Size:	76.4 KB 
ID:	36627

    Any ideas, or should I try a new approach?

    Thanks for any help!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    A crosstab is not going to accomplish what you want.

    Post example of raw data source.
    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.

  3. #3
    Jet1234 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2018
    Posts
    4
    Hey June, thanks for getting back so fast.

    The Primary key is StudentID and the foreign key is Program ID. The database is huge but this piece should be enough.

    Thanks for any info!

    Jet
    Attached Files Attached Files

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Why is ProgramYear in both tables?

    I should have said a CROSSTAB alone will not accomplish. Consider:

    Query1: OOS_Program
    SELECT Program.StudentID, OOSMap.CourseID, OOSMap.ProgramYear
    FROM Program INNER JOIN OOSMap ON Program.ProgramID = OOSMap.ProgramID;

    Query2:
    TRANSFORM First(CourseID) AS FirstOfCourseID
    SELECT StudentID, DCount("*","OOS_Program","StudentID=" & [StudentID] & " AND ProgramYear='" & [ProgramYear] & "' AND CourseID<'" & [CourseID] & "'")+1 AS GrpSeq
    FROM OOS_Program
    GROUP BY StudentID, DCount("*","OOS_Program","StudentID=" & [StudentID] & " AND ProgramYear='" & [ProgramYear] & "' AND CourseID<'" & [CourseID] & "'")+1
    PIVOT ProgramYear;

    Be aware this query will be very slow with large dataset. Alternative is VBA code writing records to a 'temp' table.
    Last edited by June7; 12-18-2018 at 03:36 PM.
    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.

  5. #5
    Jet1234 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2018
    Posts
    4
    Wow, you really saved me on this one. I never would have thought to do it that way on my own.

    Much appreciated!!!

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    @jet1234 - it seems you are using your Excel brain to design in Access. The former is column based, the latter is row based. If you continue to develop in Access that way, you will continue to struggle.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    @Micron, did you look at the db? I do think the tables are normalized but OP had a requirement to display data in non-normalized arrangement, which is what CROSSTAB is intended for.
    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.

  8. #8
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    No; maybe I misunderstood the pictures. They appear to show what now seems to be a desire to build a multi-column report but I took it the way I did because the each season repeats every year. You seem to have helped out regardless if the db is normalized or not.

    @jet1234 - apologize if the comment was unwarranted.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Crosstab Query Report
    By Xarkath in forum Reports
    Replies: 2
    Last Post: 05-03-2015, 04:35 PM
  2. report from crosstab query
    By mike02 in forum Reports
    Replies: 1
    Last Post: 07-19-2013, 12:49 PM
  3. Report From CrossTab Query
    By GSS in forum Reports
    Replies: 5
    Last Post: 02-21-2012, 05:02 PM
  4. Report using a Crosstab Query
    By Paul H in forum Reports
    Replies: 2
    Last Post: 02-09-2012, 04:35 PM
  5. Replies: 0
    Last Post: 05-09-2011, 01:51 PM

Tags for this Thread

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