VB错误91DO WHILE NOT mrc.EOF

[复制链接]
查看11 | 回复1 | 2010-6-13 10:11:56 | 显示全部楼层 |阅读模式
Private Sub cmdInquire_Click()

Dim txtSQL As String

Dim MsgText As String

Dim dd(4) As Boolean

Dim mrc As ADODB.Recordset
txtSQL = "select * from student_Info where "

If Check1(0).Value Then

If Trim(txtSID.Text) = "" Then

sMeg = "学号不能为空"

MsgBox sMeg, vbOKOnly + vbExclamation, "警告"

txtSID.SetFocus

Exit Sub

Else

If Not IsNumeric(Trim(txtSID.Text)) Then

MsgBox "请输入数字!", vbOKOnly + vbExclamation, "警告"

Exit Sub

txtSID.SetFocus

End If

dd(0) = True

txtSQL = txtSQL & "student_ID = '" & Trim(txtSID.Text) & "'"

End If

End If



If Check1(1).Value Then

If Trim(txtName.Text) = "" Then

sMeg = "姓名不能为空"

MsgBox sMeg, vbOKOnly + vbExclamation, "警告"

txtName.SetFocus

Exit Sub

Else

dd(1) = True

If dd(0) Then

txtSQL = txtSQL & "and Name = '" & txtName.Text & "'"

Else

txtSQL = txtSQL & "Name = '" & txtName.Text & "'"

End If

End If

End If



If Check1(2).Value Then

If Trim(txtClassno.Text) = "" Then

sMeg = "班号不能为空"

MsgBox sMeg, vbOKOnly + vbExclamation, "警告"

txtClassno.SetFocus

Exit Sub

Else

dd(2) = True

If dd(0) Or dd(1) Then

txtSQL = txtSQL & "and Classno = '" & txtClassno.Text & "'"

Else

txtSQL = txtSQL & "Classno = '" & txtClassno.Text & "'"

End If

End If

End If



If Not (dd(0) Or dd(1) Or dd(2) Or dd(3)) Then

MsgBox "请设置查询方式!", vbOKOnly + vbExclamation, "警告"

Exit Sub

End If



txtSQL = txtSQL & " order by student_SID "

Set mrc = ExecuteSQL(txtSQL, MsgText)



With myflexgrid

.Rows = 2

.CellAlignment = 4

.TextMatrix(1, 0) = "学号"

.TextMatrix(1, 1) = "姓名"

.TextMatrix(1, 2) = "性别"

.TextMatrix(1, 3) = "出生日期"

.TextMatrix(1, 4) = "班号"

.TextMatrix(1, 5) = "联系电话"
Do While Not mrc.EOF



.Rows = .Rows + 1

.CellAlignment = 4

.TextMatrix(.Rows - 1, 0) = mrc.Fields(0)

.TextMatrix(.Rows - 1, 1) = mrc.Fields(1)

.TextMatrix(.Rows - 1, 2) = mrc.Fields(2)

.TextMatrix(.Rows - 1, 3) = Format(mrc.Fields(3), "yyyy-mm-dd")

.TextMatrix(.Rows - 1, 4) = mrc.Fields(4)

.TextMatrix(.Rows - 1, 5) = mrc.Fields(5)

mrc.MoveNext

Loop



End With
mrc.Close
End Sub
91DO WHILE NOT mrc.EOF这一句报错了!

回复

使用道具 举报

千问 | 2010-6-13 10:11:56 | 显示全部楼层
后面两个and子串前面加个空格。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行