Results 1 to 5 of 5
  1. #1
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051

    Conditional formatting in a crosstab query

    I have a crosstab query which produces the names of students (row) vs their exam scores whilst they've been at school (value) for each exam slot (column). Currently every student appears once which is fine as it fits into a form perfectly.

    The only thing is some of the results are from a "foundation paper" and some are from a "Higher" paper and I'd like to differentiate between the two using conditional formatting.



    Every time I add the extra field [test_tier] to the crosstab I get more rows than I want with many students appearing twice where they've sat exams in two tiers.

    As a "cheat" I wondered if I could store the results as H45 or F45 depending on which level of exam they took but now I cant make the 45 appear in the textbox.

    Running out of patience.

    Hope someone can help


    Code:
    TRANSFORM Sum(IIf([tblcalendar].[papers]=1,[tblpaperstudent].[testscore]*3,[TblPaperStudent].[TestScore])) AS ts
    SELECT qryActiveStudents.Firstname, qryActiveStudents.surname
    FROM tblTestPaper INNER JOIN ((TblPaperStudent INNER JOIN tblCalendar ON TblPaperStudent.SlotID_FK = tblCalendar.SlotID_PK) INNER JOIN qryActiveStudents ON TblPaperStudent.studentID_FK = qryActiveStudents.StudentID_PK) ON tblTestPaper.PaperID_PK = TblPaperStudent.PaperID_FK
    WHERE (((qryActiveStudents.MathsClass) = '7a/Mm1'))
    GROUP BY qryActiveStudents.MathsClass, qryActiveStudents.Firstname, qryActiveStudents.surname, tblCalendar.Papers
    ORDER BY qryActiveStudents.surname, qryActiveStudents.Firstname
    PIVOT TblPaperStudent.SlotID_FK;

    Here's the crosstab

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    If TestScore is a number field this won't work.
    Either change the datatype or create a concatenated field in your underlying query "H" & TestScore or "F" & TestScore

    OR use IIf statement to select the H tier if it exists otherwise use F tier
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Thanks for the prompt reply.

    I've managed to store the information in an extra field but cannot get this data to display on the form as anything else but "H45" which isn't what I want.

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    That bit should be easy to solve
    If the field is called TestScore, set the form control =Mid(TestScore,2)
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Then I need to get back to my work computer I think. I attempted that sort of thing earlier at work and it didn't work. Many thanks again.

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

Similar Threads

  1. Replies: 10
    Last Post: 02-22-2018, 07:08 PM
  2. Not a crosstab but formatting a select query
    By mindbender in forum Queries
    Replies: 15
    Last Post: 09-25-2017, 06:34 AM
  3. Replies: 6
    Last Post: 08-30-2016, 05:43 AM
  4. Conditional Formatting Report from Crosstab Query
    By zmster2033 in forum Reports
    Replies: 1
    Last Post: 01-27-2014, 02:54 PM
  5. Conditional formatting in crosstab report
    By squirrelmaster in forum Reports
    Replies: 0
    Last Post: 06-24-2010, 06:31 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