Private Sub cmdInquire_Click()
Dim mrc As ADODB.Recordset
Dim msgText As String
Dim txtSQL As String
txtSQL = "select cardno,studentno,studentname,sex,department,grade,class,cash,status,comment from student_info where "
If Testtxt(cmbFields(0).Text) Then
MsgBox "请选择字段名", vbOKOnly + vbExclamation, "学生基本信息维护"
cmbFields(0).SetFocus
Exit Sub
Else
txtfields = ChangedString(cmbFields(0).Text)
End If
If Testtxt(cmbOperators(0).Text) Then
MsgBox "请选择操作符", vbOKOnly + vbExclamation, "学生基本信息维护"
cmbOperators(0).SetFocus
Exit Sub
End If
If Testtxt(txtContent(0).Text) Then
MsgBox "请添写要查询的内容", vbOKOnly + vbExclamation, "学生信息管理系统"
txtContent(0).SetFocus
Exit Sub
End If
txtSQL = txtSQL & "" & txtfields & " " & cmbOperators(0).Text & " '" & txtContent(0).Text & " '"
If Testtxt(Trim(cmbOrAnd(0).Text)) = False Then
txtfields = ChangedString(cmbOrAnd(0).Text)
txtSQL = txtSQL & " " & txtfields & ""
If Testtxt(cmbFields(1).Text) Then
MsgBox "请选择字段名", vbOKOnly + vbExclamation, "学生基本信息维护"
cmbFields(1).SetFocus
Exit Sub
Else
txtfields = ChangedString(cmbFields(1))
End If
If Testtxt(cmbOperators(1).Text) Then
MsgBox "请选择操作符", vbOKOnly + vbExclamation, "学生基本信息维护"
cmbOperators(1).SetFocus
Exit Sub
End If
If Testtxt(txtContent(1).Text) Then
MsgBox "请添写要查询的内容", vbOKOnly + vbExclamation, "学生信息管理系统"
txtContent(1).SetFocus
Exit Sub
End If
txtSQL = txtSQL & " " & txtfields & " " & cmbOperators(0).Text & "'" & txtContent(1).Text & "'"
End If
If Testtxt(cmbOrAnd(1).Text) = False Then
txtfields = ChangedString(cmbOrAnd(1).Text)
txtSQL = txtSQL & "" & txtfields & ""
If Testtxt(cmbFields(2).Text) Then
MsgBox "请选择字段名", vbOKOnly + vbExclamation, "学生基本信息维护"
cmbFields(2).SetFocus
Exit Sub
Else
txtfields = ChangedString(cmbFields(2).Text)
End If
If Testtxt(cmbOperators(2).Text) Then
MsgBox "请选择操作符", vbOKOnly + vbExclamation, "学生基本信息维护"
cmbOperators(2).SetFocus
Exit Sub
End If
If Testtxt(txtContent(2).Text) Then
MsgBox "请添写要查询的内容", vbOKOnly + vbExclamation, "学生信息管理系统"
txtContent(0).SetFocus
Exit Sub
End If
txtSQL = txtSQL & " " & txtfields & "" & cmbOperators(2).Text & " '" & txtContent(2).Text & "'"
End If
Set mrc = ExecuteSQL(txtSQL, msgText)
With FlexGridSt
.Rows = 1
.Cols = 10
.TextMatrix(0, 0) = "卡号"
.ColWidth(0) = 1800
.TextMatrix(0, 1) = "学号"
.ColWidth(1) = 1800
.TextMatrix(0, 2) = "姓名"
.TextMatrix(0, 3) = "性别"
.TextMatrix(0, 4) = "系别"
.ColWidth(4) = 1800
.TextMatrix(0, 5) = "年级"
.TextMatrix(0, 6) = "班级"
.TextMatrix(0, 7) = "金额"
.TextMatrix(0, 8) = "状态"
.ColWidth(8) = 1800
.TextMatrix(0, 9) = "备注"
Do While Not mrc.EOF
.Rows = .Rows + 1
For i = 0 To 9
.TextMatrix(.Rows - 1, i) = mrc.Fields(i)
Next i
mrc.MoveNext
Loop
End With
End Sub