Vb代码运行时总是提示:对象关闭时,不允许操作。
以下是代码,求高手指点!十万火急!DimstrsqlAsStringDimRSAsNewAdodb.RecordsetPrivateSubForm_Load()Me.子窗...
以下是代码,求高手指点!十万火急!
Dim strsql As String
Dim RS As New Adodb.Recordset
Private Sub Form_Load()
Me.子窗体.Form.RecordSource = "Select * Form 成绩 Where 学号 ='" & "'"
Me.Cbo1.RowSource = "Select 学院.学院编号 + 学院.学院名称 Form 学院"
End Sub
Private Sub Cbo1_afterUpdate()
Me.Cbo2.RowSource = "Select 系.系编号 + 系.系名称 from 系 Where 学院编号 = '" & Left(Cbo1.Text, 1) & " '"
End Sub
Private Sub Cbo2_AfterUpdate()
Me.Cbo4.RowSource = "select 班级.班级编号 from 班级 where 系编号='" & Left(Cbo2.Value, 2) & "'"
End Sub
Private Sub Cbo3_AfterUpdate()
Me.Cbo5.RowSource = "select 课程.课程编号+课程.课程名 from 课程 where 学期 = " & Cbo3.Text
End Sub
Private Sub Cbo5_afterUpdate()
Dim RS As New Adodb.Recordset
strsql = " Select 课程.学分 Form 课程 Where 课程编号 ='" & Left(Cbo5.Text, 5) & "'"
RS.Open strsql, CurrentProject.Connection, adOpenStatic, adLockOptimistic
Me.Txt1.Value = RS!学分
RS.Close
Set RS = Nothing
End Sub
Private Sub Cbo4_AfterUpdate()
Me.Cbo6.RowSource = "Select 学生.学号 From 学生 Where 班级编号 = '" & Cbo4.Text & "'"
End Sub
Private Sub Cmd1_Click()
Dim RS As New Adodb.Recordset
If IsNull(Me.Cbo1.Value) Then
MsgBox "请选择学生所在学院!!!", vbOKOnly + vbInformation, "提示"
Me.Cbo1.SetFocus
Exit Sub
End If
If IsNull(Me.Cbo2.Value) Then
MsgBox "请选择学生所在系!!!", vbOKOnly + vbInformation, "提示"
Me.Cbo2.SetFocus
Exit Sub
End If
If IsNull(Me.Cbo3.Value) Then
MsgBox "请选择学期!!!", vbOKOnly + vbInformation, "提示"
Me.Cbo3.SetFocus
Exit Sub
End If
If IsNull(Me.Cbo4.Value) Then
MsgBox "请选择班级!!!", vbOKOnly + vbInformation, "提示"
Me.Cbo4.SetFocus
Exit Sub
End If
If IsNull(Me.Cbo5.Value) Then
MsgBox "请选择课程!!!", vbOKOnly + vbInformation, "提示"
Me.Cbo5.SetFocus
Exit Sub
End If
If IsNull(Me.Cbo6.Value) Then
MsgBox "请选择学号!!! ", vbOKOnly + vbInformation, "提示"
Me.Cbo6.SetFocus
Exit Sub
End If
If IsNull(Me.Txt2.Value) Then
MsgBox "请输入成绩!!! ", vbOKOnly + vbInformation, "提示"
Me.Txt2.SetFocus
Exit Sub
End If
RS.AddNew
RS!学号 = Me.Cbo6.Value
RS!课程编号 = Left(Me.Cbo5.Value, 5)
RS!成绩 = Val(Me.Txt2.Value)
RS.Update
RS.Close
Set RS = Nothing
M.子窗体.Form.RecordSource = "Select * Form 成绩 Where 学号 = '" & Cbo6.Value & "'"
End Sub
Private Sub Cmd2_Click()
DoCmd.Close acForm, "学生成绩录入"
End Sub
Private Sub Cmd3_Click()
Me.子窗体.Form.RecordSource = "Select * Form 成绩 "
End Sub 展开
Dim strsql As String
Dim RS As New Adodb.Recordset
Private Sub Form_Load()
Me.子窗体.Form.RecordSource = "Select * Form 成绩 Where 学号 ='" & "'"
Me.Cbo1.RowSource = "Select 学院.学院编号 + 学院.学院名称 Form 学院"
End Sub
Private Sub Cbo1_afterUpdate()
Me.Cbo2.RowSource = "Select 系.系编号 + 系.系名称 from 系 Where 学院编号 = '" & Left(Cbo1.Text, 1) & " '"
End Sub
Private Sub Cbo2_AfterUpdate()
Me.Cbo4.RowSource = "select 班级.班级编号 from 班级 where 系编号='" & Left(Cbo2.Value, 2) & "'"
End Sub
Private Sub Cbo3_AfterUpdate()
Me.Cbo5.RowSource = "select 课程.课程编号+课程.课程名 from 课程 where 学期 = " & Cbo3.Text
End Sub
Private Sub Cbo5_afterUpdate()
Dim RS As New Adodb.Recordset
strsql = " Select 课程.学分 Form 课程 Where 课程编号 ='" & Left(Cbo5.Text, 5) & "'"
RS.Open strsql, CurrentProject.Connection, adOpenStatic, adLockOptimistic
Me.Txt1.Value = RS!学分
RS.Close
Set RS = Nothing
End Sub
Private Sub Cbo4_AfterUpdate()
Me.Cbo6.RowSource = "Select 学生.学号 From 学生 Where 班级编号 = '" & Cbo4.Text & "'"
End Sub
Private Sub Cmd1_Click()
Dim RS As New Adodb.Recordset
If IsNull(Me.Cbo1.Value) Then
MsgBox "请选择学生所在学院!!!", vbOKOnly + vbInformation, "提示"
Me.Cbo1.SetFocus
Exit Sub
End If
If IsNull(Me.Cbo2.Value) Then
MsgBox "请选择学生所在系!!!", vbOKOnly + vbInformation, "提示"
Me.Cbo2.SetFocus
Exit Sub
End If
If IsNull(Me.Cbo3.Value) Then
MsgBox "请选择学期!!!", vbOKOnly + vbInformation, "提示"
Me.Cbo3.SetFocus
Exit Sub
End If
If IsNull(Me.Cbo4.Value) Then
MsgBox "请选择班级!!!", vbOKOnly + vbInformation, "提示"
Me.Cbo4.SetFocus
Exit Sub
End If
If IsNull(Me.Cbo5.Value) Then
MsgBox "请选择课程!!!", vbOKOnly + vbInformation, "提示"
Me.Cbo5.SetFocus
Exit Sub
End If
If IsNull(Me.Cbo6.Value) Then
MsgBox "请选择学号!!! ", vbOKOnly + vbInformation, "提示"
Me.Cbo6.SetFocus
Exit Sub
End If
If IsNull(Me.Txt2.Value) Then
MsgBox "请输入成绩!!! ", vbOKOnly + vbInformation, "提示"
Me.Txt2.SetFocus
Exit Sub
End If
RS.AddNew
RS!学号 = Me.Cbo6.Value
RS!课程编号 = Left(Me.Cbo5.Value, 5)
RS!成绩 = Val(Me.Txt2.Value)
RS.Update
RS.Close
Set RS = Nothing
M.子窗体.Form.RecordSource = "Select * Form 成绩 Where 学号 = '" & Cbo6.Value & "'"
End Sub
Private Sub Cmd2_Click()
DoCmd.Close acForm, "学生成绩录入"
End Sub
Private Sub Cmd3_Click()
Me.子窗体.Form.RecordSource = "Select * Form 成绩 "
End Sub 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询