给你一段代码自己研究研究,SQL数据库就根据用到的字段自己建一个,遇到什么问题在提出来!
Private Sub comZB_Click()
If Combo3.Text <> Combo4.Text Then
List4.Clear
newcnn.Open cnstr
I = 0
Do While I < List3.ListCount
If List3.Selected(I) = True Then
SQL1 = "update 学生档案表 set 学号='" & Left(List3.list(I), 1) & Mid(Trim(Combo4.Text), 2, 1) & Mid(List3.list(I), 3, 4) & "',年级='" & Left(Trim(Combo4.Text), 1) & "班',班级='" & Mid(Trim(Combo4.Text), 2, 1) & "' WHERE 学号 ='" & Left(List3.list(I), 6) & "'"
newcnn.Execute SQL1
SQL2 = "update 余额表 set 学号='" & Left(List3.list(I), 1) & Mid(Trim(Combo4.Text), 2, 1) & Mid(List3.list(I), 3, 4) & "' WHERE 学号 ='" & Left(List3.list(I), 6) & "'"
newcnn.Execute SQL2
List3.RemoveItem I
Else
I = I + 1
End If
List3.Refresh
Loop
newcnn.Close
Adodc2.RecordSource = "select * from 学生档案表 where 年级 ='" & Left(Trim(Combo4.Text), 1) & "班' and 班级 ='" & Mid(Trim(Combo4.Text), 2, 1) & "' order by 学号"
Adodc2.Refresh
If Adodc2.Recordset.BOF = False Then Adodc2.Recordset.MoveFirst
For I = 0 To Adodc2.Recordset.RecordCount - 1
If Len(Trim(Adodc2.Recordset.Fields("学号"))) = 6 Then
List4.AddItem (Trim(Adodc2.Recordset("学号")) & "--" & Trim(Adodc2.Recordset.Fields("姓名")))
Adodc2.Recordset.MoveNext
End If
Next
If List4.ListCount > 0 Then List4.ListIndex = 0
Else
MsgBox ("请确定转至哪个班级!"), vbOKOnly, "提示"
Combo4.SetFocus
End If
End Sub