Student markbook db - access 2013 - multiple table joins

Markthearm

New Member
Joined
Jun 20, 2018
Messages
6
Hi all,
hoping for some help...
I've constructed a student mark book database with the following tables -

[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD][TABLE="width: 100"]
<tbody>[TR]
[TD]TblStudents[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]TblResults[/TD]
[TD]TblAssessment[/TD]
[/TR]
[TR]
[TD]StudentID[/TD]
[TD]ResultsID[/TD]
[TD]AssessmentID[/TD]
[/TR]
[TR]
[TD]StudentEmail[/TD]
[TD]StudentID[/TD]
[TD]Title[/TD]
[/TR]
[TR]
[TD]StudentName[/TD]
[TD]AssessmentID[/TD]
[TD]Date[/TD]
[/TR]
[TR]
[TD]Tutor[/TD]
[TD]Mark[/TD]
[TD]TotalMarks[/TD]
[/TR]
[TR]
[TD]Gender[/TD]
[TD][/TD]
[TD]Test,Y/N[/TD]
[/TR]
[TR]
[TD]MTG[/TD]
[TD][/TD]
[TD]Year12?[/TD]
[/TR]
[TR]
[TD]Group[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]TutorGroup[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]StudentInactive[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]AQAASBiologyGrade[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

works great, typical result being:

[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD]FrmShowResults[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]StudentName[/TD]
[TD]Title[/TD]
[TD]Mark[/TD]
[/TR]
[TR]
[TD]Doe, John[/TD]
[TD]DNA HW[/TD]
[TD]19[/TD]
[/TR]
[TR]
[TD]Doe, John[/TD]
[TD]Plant cells[/TD]
[TD]12[/TD]
[/TR]
[TR]
[TD]Smith, Jane[/TD]
[TD]DNA HW[/TD]
[TD]17[/TD]
[/TR]
[TR]
[TD]Smith, Jayne[/TD]
[TD]Plant cells[/TD]
[TD]20[/TD]
[/TR]
</tbody>[/TABLE]

However, the head of department has asked me if I can modify the db to show all students / all assessments on the same form, like this -

[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD]FrmShowResults[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]StudentName[/TD]
[TD]Title[/TD]
[TD]Mark[/TD]
[TD]Title[/TD]
[TD]Mark[/TD]
[/TR]
[TR]
[TD]Doe, John[/TD]
[TD]DNA HW[/TD]
[TD]19[/TD]
[TD]Plant cells[/TD]
[TD]12[/TD]
[/TR]
[TR]
[TD]Smith, Jane[/TD]
[TD]DNA HW[/TD]
[TD]17[/TD]
[TD]Plant cells[/TD]
[TD]20[/TD]
[/TR]
</tbody>[/TABLE]

Racked my brains trying to figure this out. Tried DLookup, but slow and there are over 60 assessments in the db.
Also tried adding copies of TblAssessment in the query builder, which worked, but I would need 60 copies of tblAssessment which would produce, I imagine, a huge SQL statement, with joins to each table. For example, just five copies of the AssessmentID table proudces the following SQL statement:

SELECT [TblResults redesign].StudentID, TblStudents.StudentName, [TblAssessment 1].Title, [TblResults redesign].Mark1, [TblAssessment 2].Title, [TblResults redesign].Mark2, [TblAssessment 3].Title, [TblResults redesign].Mark3, [TblAssessment 4].Title, [TblResults redesign].Mark4, [TblAssessment 5].Title, [TblResults redesign].Mark5
FROM TblStudents INNER JOIN ((((([TblResults redesign] INNER JOIN [TblAssessment 1] ON [TblResults redesign].Assessment1ID = [TblAssessment 1].Assessment1ID) INNER JOIN [TblAssessment 2] ON [TblResults redesign].Assessment2ID = [TblAssessment 2].Assessment2ID) INNER JOIN [TblAssessment 3] ON [TblResults redesign].Assessment3ID = [TblAssessment 3].Assessment3ID) INNER JOIN [TblAssessment 4] ON [TblResults redesign].Assessment4ID = [TblAssessment 4].Assessment4ID) INNER JOIN [TblAssessment 5] ON [TblResults redesign].Assessment5ID = [TblAssessment 5].Assessment5ID) ON TblStudents.StudentID = [TblResults redesign].StudentID
WHERE ((([TblResults redesign].StudentID)=1));

I feel sure there must be an easier way, but my Access/SQL knowledge doesn't stretch that far. I can find my way around VBA, although I am self taught, so a possible coding solution may help.

Thanks for any advice offered, even if it's 'no you can't really do that with a database', in which case I would pursue an Excel solution.
 
This is done with a cross tab query.
Code:
TRANSFORM Sum(Table4.Mark) AS SumOfMark
SELECT Table4.Assessment
FROM Table4
GROUP BY Table4.Assessment
PIVOT Table4.Student;

In the query builder you just add the row field (Student), Column Field (Assessment), and Value/Sum Field (Mark) - although here of course the summing of a single value is just the value itself.

However, it sounds like you might be a lot more comfortable using Excel.
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Brilliant. Works great. Thanks xenou.
PS: Yes, I am more confident in Excel, but I can see the value of a db for this and I'm interested in learning more about databases. :)
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top