غير كود الزر الى:
DoCmd.RunCommand acCmdSaveRecord
Dim Allsum As Double
Dim Part1Sum As Double
Dim Part2Sum As Double
Dim Part3Sum As Double
Dim NewSum As Double
NewSum = 0
Dim Db As DAO.Database
Dim rst As Recordset
Dim rstA As Recordset
Set Db = CurrentDb
Set rstA = Db.OpenRecordset("SELECT strDepartment_ID,degree FROM tblemploi GROUP BY strDepartment_ID,degree")
rstA.MoveFirst
Do Until rstA.EOF
Set rst = Db.OpenRecordset("SELECT * FROM tblemploi WHERE tblemploi.strDepartment_ID ='" & rstA!strDepartment_ID & "' AND tblemploi.degree=" & rstA!degree & " ORDER BY notedegree DESC")
rst.MoveFirst
Allsum = DSum("[notedegree]", "tblemploi", "[degree]=" & rstA![degree] & " And [strDepartment_ID]='" & rstA![strDepartment_ID] & "'")
Part1Sum = Allsum / 100 * 40
Part2Sum = Allsum / 100 * 80
Do Until rst.EOF
rst.Edit
If NewSum <= Part1Sum Then
rst![mod] = "الدنيا"
Else
If NewSum <= Part2Sum Then
rst![mod] = "الوسطى"
Else
rst![mod] = "القصوى"
End If
End If
rst.Update
NewSum = NewSum + rst![notedegree]
rst.MoveNext
Loop
NewSum = 0
rstA.MoveNext
Loop
Set rst = Nothing
Set Db = Nothing
Set rstA = Nothing
'DoCmd.SetOrderBy "notedegree DESC"
Form.Requery