100分求助 实时错误 91

mark1126 2005-06-07 11:31:17
Private Sub Command1_Click()
Dim txtsql As String
If Text1(1) = "" Then
MsgBox "考试期号不能为空!", vbOKOnly, "提示"
Text1(1).SetFocus
Exit Sub
End If
If Combo1(0).Text = "" Then
MsgBox "学生班号不能为空!", vbOKOnly, "提示"
Combo1(0).SetFocus
Exit Sub
End If
If Combo1(1).Text = "" Then
MsgBox "学生编号不能为空!", vbOKOnly, "提示"
Combo1(1).SetFocus
Exit Sub
End If
If Combo1(2).Text = "" Then
MsgBox "考试课程不能为空!", vbOKOnly, "提示"
Combo1(2).SetFocus
Exit Sub
End If
If Text1(2) = "" Then
MsgBox "考试分数不能为空!", vbOKOnly, "提示"
Text1(2).SetFocus
Exit Sub
End If
txtsql = "select * from score_Form where score_Per='" & Trim(Text1(1)) & "' and score_Cla='" & Trim(Combo1(0).Text) & "' and score_Stu='" & Trim(Combo1(1).Text) & "'And score_Cou='" & Trim(Combo1(2).Text) & "'"
Set mrc = ExecuteSQL(txtsql, MsgText)
If mrc.EOF = False Then
MsgBox "同次同人同科只能添加一次", vbOKOnly, "警告"
Text1(2) = ""
Combo1(0).SetFocus
Exit Sub
End If
txtsql = "select * from score_Form"
Set mrc = ExecuteSQL(txtsql, MsgText)
mrc.AddNew
mrc.Fields(0) = Trim(Text1(0))
mrc.Fields(1) = Trim(Text1(1))
mrc.Fields(2) = Trim(Combo1(0).Text)
mrc.Fields(3) = Trim(Combo1(1).Text)
mrc.Fields(4) = Trim(Combo1(2).Text)
mrc.Fields(5) = Trim(Text1(2))
mrc.Update
mrc.Close
MsgBox "考试信息添加成功!", vbOKOnly, "提示"
With MSFlexGrid1
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 0) = Trim(Text1(0))
.TextMatrix(.Rows - 1, 1) = Trim(Text1(1))
.TextMatrix(.Rows - 1, 2) = Trim(Combo1(0).Text)
.TextMatrix(.Rows - 1, 3) = Trim(Combo1(1).Text)
.TextMatrix(.Rows - 1, 4) = Trim(Combo1(2).Text)
.TextMatrix(.Rows - 1, 5) = Trim(Text1(2))
End With
Text1(0) = GetRkno
MSFlexGrid1.TopRow = MSFlexGrid1.Rows - 1
MsgBox "请输入下一科成绩", vbOKOnly, "提示"
End Sub

Private Sub Command2_Click()
Dim txtsql As String
Text1(0) = GetRkno
Text1(1) = ""
Text1(2) = ""
Combo1(0).Clear
txtsql = "select * from class_Form"
Set mrc = ExecuteSQL(txtsql, MsgText)
If mrc.EOF = False Then
With Combo1(0)
.Clear
Do While Not mrc.EOF
.AddItem Trim(mrc!class_NO)
mrc.MoveNext
Loop
End With
End If
Combo1(1).Clear
Combo1(2).Clear
End Sub

Private Sub Command3_Click()
Dim j As Long
Dim txtsql As String
Dim txSQL As String
txtsql = "SELECT score_Form.score_Per, score_Form.score_Cla, score_Form.score_Stu, score_Form.score_Cou, score_Form.score_Sco, student_Form.student_Name FROM student_Form INNER JOIN score_Form ON student_Form.student_NO=score_Form.score_Stu"
If Text2(1) <> "" Then
txtsql = "SELECT score_Form.score_Per, score_Form.score_Cla, score_Form.score_Stu, score_Form.score_Cou, score_Form.score_Sco, student_Form.student_Name FROM student_Form INNER JOIN score_Form ON student_Form.student_NO=score_Form.score_Stu where score_Form.score_Per='" & Trim(Text2(1)) & "'"
End If
If Combo2(0).Text <> "" Then
If txtsql = "SELECT score_Form.score_Per, score_Form.score_Cla, score_Form.score_Stu, score_Form.score_Cou, score_Form.score_Sco, student_Form.student_Name FROM student_Form INNER JOIN score_Form ON student_Form.student_NO=score_Form.score_Stu " Then
txtsql = txtsql & "where score_Cla='" & Trim(Combo2(0).Text) & "'"
Else
txtsql = txtsql & "and score_Cla='" & Trim(Combo2(0).Text) & "'"
End If
End If
If Combo2(1).Text <> "" Then
If txtsql = "SELECT score_Form.score_Per, score_Form.score_Cla, score_Form.score_Stu, score_Form.score_Cou, score_Form.score_Sco, student_Form.student_Name FROM student_Form INNER JOIN score_Form ON student_Form.student_NO=score_Form.score_Stu " Then
txtsql = txtsql & "where score_Stu='" & Trim(Combo2(1).Text) & "'"
Else
txtsql = txtsql & "and score_Stu='" & Trim(Combo2(1).Text) & "'"
End If
End If
If Combo2(2).Text <> "" Then
If txtsql = "SELECT score_Form.score_Per, score_Form.score_Cla, score_Form.score_Stu, score_Form.score_Cou, score_Form.score_Sco, student_Form.student_Name FROM student_Form INNER JOIN score_Form ON student_Form.student_NO=score_Form.score_Stu " Then
txtsql = txtsql & "where score_Cou='" & Trim(Combo2(2).Text) & "'"
Else
txtsql = txtsql & "and score_Cou='" & Trim(Combo2(2).Text) & "'"
End If
End If
If Text2(3).Text <> "" Then
If txtsql = "SELECT score_Form.score_Per, score_Form.score_Cla, score_Form.score_Stu, score_Form.score_Cou, score_Form.score_Sco, student_Form.student_Name FROM student_Form INNER JOIN score_Form ON student_Form.student_NO=score_Form.score_Stu " Then
txtsql = txtsql & "where student_Name like '" & "%" & Trim(Text2(3).Text) & "%" & "' order by student_name"
Else
txtsql = txtsql & "and student_Name like '" & "%" & Trim(Text2(3).Text) & "%" & "' order by student_name"
End If
End If

Set mrc = ExecuteSQL(txtsql, MsgText)-------------错误在这--------------
j = 1
Do While Not mrc.EOF
j = j + 1
mrc.MoveNext
Loop
ProgressBar1.Visible = True
ProgressBar1.Min = CInt(0)
ProgressBar1.Max = CInt(j)
Set mrc = ExecuteSQL(txtsql, MsgText)
Frame1.Visible = True
With MSFlexGrid1
.Visible = False
.Rows = 1
ProgressBar1.Value = .Rows
Do While Not mrc.EOF
.Rows = .Rows + 1
For i = 0 To mrc.Fields.Count - 1
Select Case mrc.Fields(i).Type
Case adDBDate
.TextMatrix(.Rows - 1, i) = Format(mrc.Fields(i) & "", "yyyy-mm-dd")
Case Else
.TextMatrix(.Rows - 1, i) = mrc.Fields(i) & ""
End Select
Next i
mrc.MoveNext
Loop
.Visible = True
End With
Frame1.Visible = False
mrc.Close
Text2(1) = ""
txSQL = "select DISTINCT score_Cla from score_Form,student_Form"
Set mrc = ExecuteSQL(txSQL, MsgText)
If mrc.EOF = False Then
With Combo2(0)
.Clear
Do While Not mrc.EOF
.AddItem Trim(mrc!score_Cla)
mrc.MoveNext
Loop
End With
End If
Combo2(1).Clear
Combo2(2).Clear
Text2(2) = ""
End Sub

mrc为全局变量
...全文
108 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

1,217

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧