I have a form in which users enter exam marks for a group. In a subform the names are listed and in another sumform the Maximum marks and grade boundaries are given. Staff enter the marks and it converts them into grades using the % boundaries.
My problem is getting the command button (PreviewResults) to save the grade. I keep getting "type mismatch". I converted the database from Access 97 to 2000, if that matters.
The code I have is:
Private Sub PreviewResults_Click()
Dim y As Boolean
y = SaveGrades("Score", "MaximumPoints", "Grade")
' More odds and ends which seem to work - grading results into a report
End Sub
Function SaveGrades(Mark As Integer, Total As Integer, Grade As String)
'Allocate grades to appropriate records
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim MarkAsPerCent As Single
Set db = CurrentDb
Set rst = db.OpenRecordset("qryGroupResults")
'Start to loop through all records
Do
'Copy the current record into the copy buffer
rst.Edit
If rst(Total) <> 0 Then
'Update the grade and save it, then move on
Dim CurrentMark, CurrentTotal As Integer
CurrentMark = rst(Mark)
CurrentTotal = rst(Total)
MarkAsPerCent = (CurrentMark / CurrentTotal) * 100
Select Case rst(MarkAsPerCent)
Case Is >= [Forms]![Assignments].[CurrentA1]
rst(Grade) = "A1"
Case Is >= [Forms]![Assignments].[CurrentA2]
rst(Grade) = "A2"
‘ more of the same…
Case Is >= 0
rst(Grade) = "E"
Case Else
rst(Grade) = ""
End Select
Else
MsgBox "No grades will appear unless you indicate the total number of marks available", , "Missing data"
End If
rst.Update
rst.MoveNext
Loop Until rst.EOF
SaveGrades = True
End Function
I'd be grateful if anyone can help
Thanks
My problem is getting the command button (PreviewResults) to save the grade. I keep getting "type mismatch". I converted the database from Access 97 to 2000, if that matters.
The code I have is:
Private Sub PreviewResults_Click()
Dim y As Boolean
y = SaveGrades("Score", "MaximumPoints", "Grade")
' More odds and ends which seem to work - grading results into a report
End Sub
Function SaveGrades(Mark As Integer, Total As Integer, Grade As String)
'Allocate grades to appropriate records
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim MarkAsPerCent As Single
Set db = CurrentDb
Set rst = db.OpenRecordset("qryGroupResults")
'Start to loop through all records
Do
'Copy the current record into the copy buffer
rst.Edit
If rst(Total) <> 0 Then
'Update the grade and save it, then move on
Dim CurrentMark, CurrentTotal As Integer
CurrentMark = rst(Mark)
CurrentTotal = rst(Total)
MarkAsPerCent = (CurrentMark / CurrentTotal) * 100
Select Case rst(MarkAsPerCent)
Case Is >= [Forms]![Assignments].[CurrentA1]
rst(Grade) = "A1"
Case Is >= [Forms]![Assignments].[CurrentA2]
rst(Grade) = "A2"
‘ more of the same…
Case Is >= 0
rst(Grade) = "E"
Case Else
rst(Grade) = ""
End Select
Else
MsgBox "No grades will appear unless you indicate the total number of marks available", , "Missing data"
End If
rst.Update
rst.MoveNext
Loop Until rst.EOF
SaveGrades = True
End Function
I'd be grateful if anyone can help
Thanks