A family of Microsoft relational database management systems designed for ease of use.
Frankly, I'm a little stumped. I don't really understand why the first query works and the second one doesn't. However, there is a work around.
What I would do is create a table to be used temporarily to store the data used for the crosstab.
You will then need to expand the code behind your Generate Report button:
Dim strSQL as String
strSQL = "DELETE * FROM tmpProgress;"
CurrentDB.Execute strSQL, dbFailOnError
strSQL = "INSERT INTO tmpProgress (CenterCode, StudentID, GradeScore, CourseName) " & _
"SELECT CenterCode, StudentID, GradeScore, CourseName " & _
"FROM qryStudentProgress_FIRST_SIMPLE_QUERY;"
CurrentDB.Execute strSQL, dbFailOnError
DoCmd.OpenReport "frmSimpleUsingCrosstabasSource", acViewPreview, , "CenterCode= " & Me.Centercode
I would create a new crosstab query using the temp table:
TRANSFORM Sum(tmpProgress.GradeScore) AS SumOfGradeScore
SELECT tmpProgress.CenterCode, tmpProgress.StudentID, Sum(tmpProgress.GradeScore) AS [Total Of GradeScore]
FROM tmpProgress
GROUP BY tmpProgress.CenterCode, tmpProgress.StudentID
PIVOT tmpProgress.CourseName;
I would also create the following query that would be the recordsource of the report:
SELECT qryProgress_Crosstab.StudentID, tblStudents.StudentName, qryProgress_Crosstab.CenterCode, qryProgress_Crosstab.English, qryProgress_Crosstab.Hindi, qryProgress_Crosstab.Math, qryProgress_Crosstab.Science, [total Of GradeScore]/4 AS Percentage
FROM tblStudents INNER JOIN qryProgress_Crosstab ON tblStudents.StudentID = qryProgress_Crosstab.StudentID;
Note: I don't think I have the expression for percentage correct. so you may need to change that.
So with the temp table, the 2 new queries and the changes to the code, it should work.
By the way, GradeScore should be a number datatype, not text.