Option Compare Database
Private Sub 命令0_Click()
On Error GoTo Err_命令0_Click
'定义变量,分配空间'
Dim var As Variant
Dim rs As Recordset
Dim sql As String
Dim cnn As ADODB.Connection
'初始化变量和对象'
Set cnn = CurrentProject.Connection
Set rs = New ADODB.recordset
sql = "SELECT top 2 核对查询.班级, 核对查询.学号, 核对查询.姓名, 核对查询.院部, 核对查询.专业, 核对查询.加权成绩"
sql = sql + "into 1 FROM 名次查询"
sql = sql + "ORDER BY 核对查询.班级, 核对查询.加权成绩 DESC;"
rs.Open "名次查询", , adOpenKeyset, adLockOptimistic, adCmdTable
'循环操作'
var = 3403
Do Until rs.EOF
If rs!班级 = var Then
cnn.Execute sql
var = var + 1
rs.MoveNext
Loop
Else
End If
rs.Close
Set .rs = Nothing
Exit_命令0_Click:
Exit Sub
Err_命令0_Click:
MsgBox Err.Description
Resume Exit_命令0_Click
End Sub
[此贴子已经被作者于2004-9-17 14:29:01编辑过]
|