Dim aa As Integer
aa = Round(DSum("成绩合成", "汇总成绩查询") / 125)
Dim Conn1 As New ADODB.Connection
Dim Rs_Date As New ADODB.Recordset
Set Conn1 = CurrentProject.Connection
Dim Arr_Date()
Dim sql As String
Dim rstCount As Integer
Do While True
CurrentDb.CreateQueryDef "文班1班", "SELECT TOP 62 文科慢班.ID, Sum(文科慢班.成绩合成) AS 成绩合成之合计 FROM 文科慢班 GROUP BY 文科慢班.ID ORDER BY Rnd(-(ID+Rnd()))"
sql = "SELECT round(Sum(文班1班.成绩合成之合计)) AS 班级成绩总和 FROM 文班1班"
Rs_Date.Open sql, Conn1, 3, 3
Debug.Print Round(Rs_Date(0) / 62)
If Abs(Round(Rs_Date(0) / 62) - aa) < 1 Then
GoTo line
End If
DoCmd.DeleteObject acQuery, "文班1班"
Rs_Date.Close
Set Rs_Date = Nothing
Loop
line:
MsgBox "文班慢班1完成!其余为慢班2班"
试验了一下,应该可以实现,我用的是access