MajP
You've got your good things, and you've got mine.
- Local time
- Today, 18:27
- Joined
- May 21, 2018
- Messages
- 8,932
I played with this a little. Here are some functions I found very reuseable
These are useful for doing all the checks I talked about. How many questions inserted, answered, required, AllQuestionsCompleted.
It will turn green once all questions are filled in.
It will prompt you to do the insert query when you click on a person that does not have question filled in
If your results are like 1 to 5. Then I would have the marks textbox trap up arrow and down arrow. Up it adds 1 down it subtracts 1. That way you do all entries with 3 fingers on the keyboard. Tab, up arrow, up arrow,... Tab to next question. But if not it is tab, keypad, tab, keypad because the other fields are disabled.
Code:
Public Function GetTotalQuestions(ExamPaperID As Long) As Long
GetTotalQuestions = DCount("*", "tblQuestions", "ExamPaperID = " & ExamPaperID)
End Function
Public Function GetTotalQuestions_2(ExamPaperRef As String) As Long
Dim ExamPaperID As Long
ExamPaperID = DLookup("examPaperID", "tblExamPapers", "ExamPaperRef = '" & ExamPaperRef & "'")
GetTotalQuestions_2 = DCount("*", "tblQuestions", "ExamPaperId = " & ExamPaperID)
End Function
Public Function GetCompletedQuestions(TestID As Long) As Long
'A test id uniquely describes a student taking the test.
GetCompletedQuestions = DCount("*", "tblResults", "TestID = " & TestID & " AND NOT Score is Null")
End Function
Public Function AllResultsCompleted(TestID As Long) As Boolean
'Used to determine if you have
Dim ExamPaperID As Long
Dim completed As Long
Dim total As Long
ExamPaperID = GetExamFromTest(TestID)
total = GetTotalQuestions(ExamPaperID)
completed = GetCompletedQuestions(TestID)
If total = completed And total <> 0 Then AllResultsCompleted = True
End Function
Public Function GetExamFromTest(TestID As Long) As Long
GetExamFromTest = DLookup("examPaperID", "tblTests", "TestID = " & TestID)
End Function
Public Function QuestionsInserted(TestID As Long) As Boolean
'Determine if you have inserted dummy records
Dim existing As Long
Dim required As Long
Dim ExamPaperID As Long
existing = DCount("*", "tblResults", "TestID = " & TestID)
If existing > 0 Then QuestionsInserted = True
End Function
Public Function GetStudentName(StudentID As Long) As String
GetStudentName = DLookup("Fullname", "tblStudents", "StudentID = " & StudentID)
End Function
These are useful for doing all the checks I talked about. How many questions inserted, answered, required, AllQuestionsCompleted.
It will turn green once all questions are filled in.
It will prompt you to do the insert query when you click on a person that does not have question filled in
If your results are like 1 to 5. Then I would have the marks textbox trap up arrow and down arrow. Up it adds 1 down it subtracts 1. That way you do all entries with 3 fingers on the keyboard. Tab, up arrow, up arrow,... Tab to next question. But if not it is tab, keypad, tab, keypad because the other fields are disabled.
Attachments
Last edited: