学生信息维护这个窗体单拿出来是为了修改其中的记录而做的介绍。其中将详细列出代码请参考代码
具体的代码
添加字段名
Private Sub Form_Load()
H = Me.Height
W = Me.Width
'为字段添加选项
comboFieldName1.AddItem "卡号"
comboFieldName1.AddItem "学号"
comboFieldName1.AddItem "姓名"
comboFieldName1.AddItem "性别"
comboFieldName1.AddItem "系别"
comboFieldName1.AddItem "年级"
comboFieldName1.AddItem "班级"
comboFieldName1.AddItem " "
comboFieldName2.AddItem "卡号"
comboFieldName2.AddItem "学号"
comboFieldName2.AddItem "姓名"
comboFieldName2.AddItem "性别"
comboFieldName2.AddItem "系别"
comboFieldName2.AddItem "年级"
comboFieldName2.AddItem "班级"
comboFieldName2.AddItem " "
comboFieldName3.AddItem "卡号"
comboFieldName3.AddItem "学号"
comboFieldName3.AddItem "姓名"
comboFieldName3.AddItem "性别"
comboFieldName3.AddItem "系别"
comboFieldName3.AddItem "年级"
comboFieldName3.AddItem "班级"
comboFieldName3.AddItem " "
'为性别添加选项
comboSEX1.AddItem "男"
comboSEX1.AddItem "女"
comboSEX1.AddItem " "
comboSEX2.AddItem "男"
comboSEX2.AddItem "女"
comboSEX2.AddItem " "
comboSEX3.AddItem "男"
comboSEX3.AddItem "女"
comboSEX3.AddItem " "
'为操作符添加选项
comboChar1.AddItem "="
comboChar1.AddItem "<>"
comboChar1.AddItem " "
comboChar2.AddItem "="
comboChar2.AddItem "<>"
comboChar2.AddItem " "
comboChar3.AddItem "="
comboChar3.AddItem "<>"
comboChar3.AddItem " "
'为组添加选项
comboGroup1.AddItem "And"
comboGroup1.AddItem "Or"
comboGroup1.AddItem " "
comboGroup2.AddItem "And"
comboGroup2.AddItem "Or"
comboGroup2.AddItem " "
comboFieldName2.Enabled = False
comboFieldName3.Enabled = False
comboChar2.Enabled = False
comboChar3.Enabled = False
comboGroup2.Enabled = False
txtInquery2.Enabled = False
txtInquery3.Enabled = False
comboSEX2.Enabled = False
comboSEX3.Enabled = False
txtInquery1.Visible = True
txtInquery2.Visible = True
txtInquery3.Visible = True
comboSEX1.Visible = False
comboSEX2.Visible = False
comboSEX3.Visible = False
cmdModify.Enabled = False
With MSHFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "卡号"
.TextMatrix(0, 3) = "金额"
.TextMatrix(0, 4) = "系别"
.TextMatrix(0, 5) = "年级"
.TextMatrix(0, 6) = "班级"
.TextMatrix(0, 7) = "性别"
.TextMatrix(0, 8) = "状态"
.TextMatrix(0, 9) = "类型"
.TextMatrix(0, 10) = "备注"
.TextMatrix(0, 11) = "日期"
.TextMatrix(0, 12) = "时间"
End With
End Sub
修改学生信息
Private Sub cmdModify_Click()
frmModifyStudentInformation.Show
Me.Hide
End Sub
修改窗体的代码
Dim H As Single '定义窗体高的变量
Dim W As Single '定义窗体高的变量
Dim mcclean As Boolean
Private Sub cmdCancel_Click()
If mcclean = False Then
cmdOK.Enabled = False
cmdCancel.Enabled = False
cmdModify.Enabled = True
MsgBox "没有修改有什么好取消的!", vbOKOnly + vbInformation, "提示"
Else
txtSID.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 0))
txtStudentName.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 1))
txtCID.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 2))
comboSex.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 7))
txtCharge.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 3))
txtDepartment.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 4))
comboStatus.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 8))
txtExplain.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 10))
txtGrade.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 5))
txtClass.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 6))
comboType.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 9))
Frame1.Enabled = False
txtSID.Enabled = False
txtCID.Enabled = False
txtStudentName.Enabled = False
txtCharge.Enabled = False
comboSex.Enabled = False
txtDepartment.Enabled = False
comboStatus.Enabled = False
txtExplain.Enabled = False
txtGrade.Enabled = False
txtClass.Enabled = False
comboType.Enabled = False
cmdOK.Enabled = False
cmdModify.Enabled = True
End If
End Sub
Private Sub cmdModify_Click()
mcclean = True
cmdOK.Enabled = True
cmdCancel.Enabled = True
Frame1.Enabled = True
txtSID.Enabled = True
txtCID.Enabled = True
txtStudentName.Enabled = True
txtCharge.Enabled = True
comboSex.Enabled = True
txtDepartment.Enabled = True
comboStatus.Enabled = True
txtExplain.Enabled = True
txtGrade.Enabled = True
txtClass.Enabled = True
comboType.Enabled = True
cmdModify.Enabled = False
End Sub
Private Sub cmdOK_Click()
'对student_info表操作
Dim mrcstudent As ADODB.Recordset '用于存放记录集
Dim studentSQL As String '用于存放SQL语句
Dim studentMsgText As String '用于存放返回信息
'限制各个控件不为空
If txtSID.Text = "" Then
MsgBox "请输入学号!", vbOKOnly + vbExclamation, "警告"
txtSID.SetFocus
Exit Sub
Else
If txtStudentName = "" Then
MsgBox "请输入姓名!", vbOKOnly + vbExclamation, "警告"
txtStudentName.SetFocus
Exit Sub
Else
If txtCID = "" Then
MsgBox "请输入卡号!", vbOKOnly + vbExclamation, "警告"
txtCID.SetFocus
Exit Sub
Else
If txtCharge = "" Then
MsgBox "请输入金额!", vbOKOnly + vbExclamation, "警告"
txtCharge.SetFocus
Exit Sub
Else
If comboSex = "" Then
MsgBox "请选择性别!", vbOKOnly + vbExclamation, "警告"
comboSex.SetFocus
Exit Sub
Else
If comboStatus = "" Then
MsgBox "请选择状态!", vbOKOnly + vbExclamation, "警告"
comboStatus.SetFocus
Exit Sub
Else
If txtDepartment = "" Then
MsgBox "请输入系别!", vbOKOnly + vbExclamation, "警告"
txtDepartment.SetFocus
Exit Sub
Else
If txtGrade = "" Then
MsgBox "请输入年级!", vbOKOnly + vbExclamation, "警告"
txtGrade.SetFocus
Exit Sub
Else
If txtClass = "" Then
MsgBox "请输入班级!", vbOKOnly + vbExclamation, "警告"
txtClass.SetFocus
Exit Sub
Else
If txtExplain = "" Then
MsgBox "请输入备注!", vbOKOnly + vbExclamation, "警告"
txtExplain.SetFocus
Exit Sub
Else
If comboType = "" Then
MsgBox "请选择类型!", vbOKOnly + vbExclamation, "警告"
comboType.SetFocus
Exit Sub
Else
studentSQL = "select * from student_info where cardno='" & Trim(txtCID.Text) & "' and studentno='" & Trim(txtSID.Text) & "'"
Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)
'更改数据表student的内容
mrcstudent.Fields(0) = Trim(txtCID.Text)
mrcstudent.Fields(1) = Trim(txtSID.Text)
mrcstudent.Fields(2) = Trim(txtStudentName.Text)
mrcstudent.Fields(3) = Trim(comboSex.Text)
mrcstudent.Fields(4) = Trim(txtDepartment.Text)
mrcstudent.Fields(5) = Trim(txtGrade.Text)
mrcstudent.Fields(6) = Trim(txtClass.Text)
mrcstudent.Fields(7) = Trim(txtCharge.Text)
mrcstudent.Fields(8) = Trim(txtExplain.Text)
mrcstudent.Fields(10) = Trim(comboStatus.Text)
mrcstudent.Fields(14) = Trim(comboType.Text)
mrcstudent.Update
mrcstudent.Close
'将更改的内容放到学生信息维护的MSHFlexGrid中
frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 0) = Trim(txtSID.Text)
frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 1) = Trim(txtStudentName.Text)
frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 2) = Trim(txtCID.Text)
frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 3) = Trim(txtCharge.Text)
frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 4) = Trim(txtDepartment.Text)
frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 5) = Trim(txtGrade.Text)
frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 6) = Trim(txtClass.Text)
frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 7) = Trim(comboSex.Text)
frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 8) = Trim(comboStatus.Text)
frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 9) = Trim(comboType.Text)
frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 10) = Trim(txtExplain.Text)
cmdOK.Enabled = False
cmdCancel.Enabled = False
cmdModify.Enabled = True
MsgBox "修改成功!", vbOKOnly + vbInformation, "提示"
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
Private Sub cmdOUT_Click()
Unload Me
frmStudentInformation.Show
End Sub
Private Sub comboSex_KeyPress(KeyAscii As Integer)
KeyAscii = 0 '不可输入值
End Sub
Private Sub comboStatus_KeyPress(KeyAscii As Integer)
KeyAscii = 0 '不可输入值
End Sub
Private Sub comboType_KeyPress(KeyAscii As Integer)
KeyAscii = 0 '不可输入值
End Sub
Private Sub Form_Load()
H = Me.Height
W = Me.Width
'为性别、类型、状态添加选项
comboSex.AddItem "男"
comboSex.AddItem "女"
comboType.AddItem "固定用户"
comboType.AddItem "临时用户"
comboStatus.AddItem "使用"
comboStatus.AddItem "未使用"
'显示学生基本信息表中的MSHFLEXGRID中的选中内容
txtSID.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 0))
txtStudentName.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 1))
txtCID.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 2))
comboSex.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 7))
txtCharge.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 3))
txtDepartment.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 4))
comboStatus.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 8))
txtExplain.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 10))
txtGrade.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 5))
txtClass.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 6))
comboType.Text = Trim(frmStudentInformation.MSHFlexGrid.TextMatrix(frmStudentInformation.MSHFlexGrid.RowSel, 9))
Frame1.Enabled = False
txtSID.Enabled = False
txtCID.Enabled = False
txtStudentName.Enabled = False
txtCharge.Enabled = False
comboSex.Enabled = False
txtDepartment.Enabled = False
comboStatus.Enabled = False
txtExplain.Enabled = False
txtGrade.Enabled = False
txtClass.Enabled = False
comboType.Enabled = False
cmdOK.Enabled = False
cmdCancel.Enabled = False
cmdModify.Enabled = True
mcclean = False
End Sub
Private Sub Form_Resize()
Me.Height = H
Me.Width = W
Me.PaintPicture Me.Picture, 0, 0, Me.ScaleWidth, Me.ScaleHeight '实现背景图随窗体变大而改变
End Sub
Private Sub txtCharge_KeyPress(KeyAscii As Integer)
If (KeyAscii < Asc("0") Or KeyAscii > Asc("9")) And KeyAscii <> 8 And KeyAscii <> Asc(".") Then
KeyAscii = 0 '不可输入值
End If
End Sub
Private Sub txtCharge_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'不可粘贴
If Button = 2 Then
Clipboard.Clear
End If
End Sub
Private Sub txtCID_KeyPress(KeyAscii As Integer)
If (KeyAscii < Asc("0") Or KeyAscii > Asc("9")) And KeyAscii <> 8 Then
KeyAscii = 0 '不可输入值
End If
End Sub
Private Sub txtCID_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'不可粘贴
If Button = 2 Then
Clipboard.Clear
End If
End Sub
Private Sub txtClass_KeyPress(KeyAscii As Integer)
If (KeyAscii <= -20319 Or KeyAscii >= -3652) And KeyAscii <> 8 And (KeyAscii < Asc("0") Or KeyAscii > Asc("9")) Then
KeyAscii = 0 '不可输入值
End If
End Sub
Private Sub txtClass_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'不可粘贴
If Button = 2 Then
Clipboard.Clear
End If
End Sub
Private Sub txtDepartment_KeyPress(KeyAscii As Integer)
If (KeyAscii <= -20319 Or KeyAscii >= -3652) And KeyAscii <> 8 Then
KeyAscii = 0 '不可输入值
End If
End Sub
Private Sub txtDepartment_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'不可粘贴
If Button = 2 Then
Clipboard.Clear
End If
End Sub
Private Sub txtExplain_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'不可粘贴
If Button = 2 Then
Clipboard.Clear
End If
End Sub
Private Sub txtGrade_KeyPress(KeyAscii As Integer)
If (KeyAscii <= -20319 Or KeyAscii >= -3652) And KeyAscii <> 8 And (KeyAscii < Asc("0") Or KeyAscii > Asc("9")) Then
KeyAscii = 0 '不可输入值
End If
End Sub
Private Sub txtGrade_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'不可粘贴
If Button = 2 Then
Clipboard.Clear
End If
End Sub
Private Sub txtSID_KeyPress(KeyAscii As Integer)
If (KeyAscii < Asc("0") Or KeyAscii > Asc("9")) And KeyAscii <> 8 Then
KeyAscii = 0 '不可输入值
End If
End Sub
Private Sub txtSID_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'不可粘贴
If Button = 2 Then
Clipboard.Clear
End If
End Sub
Private Sub txtStudentName_KeyPress(KeyAscii As Integer)
If (KeyAscii <= -20319 Or KeyAscii >= -3652) And KeyAscii <> 8 Then
KeyAscii = 0 '不可输入值
End If
End Sub
Private Sub txtStudentName_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'不可粘贴
If Button = 2 Then
Clipboard.Clear
End If
End Sub
查询操作:
Private Sub cmdInquery_Click()
'一层查询
If comboGroup1 = "" Then
If comboFieldName1.Text = "" Then
MsgBox "请选择字段名!", vbOKOnly + vbInformation, "提示"
Else
If comboChar1.Text = "" Then
MsgBox "请选择操作符!", vbOKOnly + vbInformation, "提示"
Else
Call OneInquery
End If
End If
Else
'二层查询
If comboGroup1 <> "" And comboGroup2 = "" Then
If comboFieldName1.Text = "" Then
MsgBox "请选择字段名!", vbOKOnly + vbInformation, "提示"
Else
If comboChar2.Text = "" Then
MsgBox "请选择操作符!", vbOKOnly + vbInformation, "提示"
Else
If comboFieldName2.Text = "" Then
MsgBox "请选择字段名!", vbOKOnly + vbInformation, "提示"
Else
If comboChar2.Text = "" Then
MsgBox "请选择操作符!", vbOKOnly + vbInformation, "提示"
Else
Call TwoInquery
End If
End If
End If
End If
Else
'三层查询
If comboGroup1 <> "" And comboGroup2 <> "" Then
If comboFieldName1.Text = "" Then
MsgBox "请选择字段名!", vbOKOnly + vbInformation, "提示"
Else
If comboChar2.Text = "" Then
MsgBox "请选择操作符!", vbOKOnly + vbInformation, "提示"
Else
If comboFieldName2.Text = "" Then
MsgBox "请选择字段名!", vbOKOnly + vbInformation, "提示"
Else
If comboChar2.Text = "" Then
MsgBox "请选择操作符!", vbOKOnly + vbInformation, "提示"
Else
If comboFieldName3.Text = "" Then
MsgBox "请选择字段名!", vbOKOnly + vbInformation, "提示"
Else
If comboChar3.Text = "" Then
MsgBox "请选择操作符!", vbOKOnly + vbInformation, "提示"
Else
Call ThreeInquery
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
1)一层查询
Public Sub OneInquery()
'对student_info表操作
Dim mrcstudent As ADODB.Recordset '用于存放记录集
Dim studentSQL As String '用于存放SQL语句
Dim studentMsgText As String '用于存放返回信息
studentSQL = "select * from student_info where"
If comboFieldName1.Text = "姓名" Or comboFieldName1.Text = "系别" Or comboFieldName1.Text = "年级" Or comboFieldName1.Text = "班级" _
Or comboFieldName1.Text = "卡号" Or comboFieldName1.Text = "学号" Then
If txtInquery1.Text = "" Then
MsgBox "请输入查询内容!", vbOKOnly + vbExclamation, "警告"
txtInquery1.SetFocus
Exit Sub
Else
studentSQL = studentSQL & " " & Field(Trim(comboFieldName1.Text)) & " " & Trim(comboChar1.Text) _
& "'" & Trim(txtInquery1.Text) & "'"
Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)
If mrcstudent.EOF = True Then
MSHFlexGrid.Clear
With MSHFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "卡号"
.TextMatrix(0, 3) = "金额"
.TextMatrix(0, 4) = "系别"
.TextMatrix(0, 5) = "年级"
.TextMatrix(0, 6) = "班级"
.TextMatrix(0, 7) = "性别"
.TextMatrix(0, 8) = "状态"
.TextMatrix(0, 9) = "类型"
.TextMatrix(0, 10) = "备注"
.TextMatrix(0, 11) = "日期"
.TextMatrix(0, 12) = "时间"
End With
MsgBox "该条件数据不存在!", vbOKOnly + vbInformation, "提示"
comboFieldName1.SetFocus
Exit Sub
Else
With MSHFlexGrid
.Rows = 1
Do While mrcstudent.EOF = False
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrcstudent.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrcstudent.Fields(2))
.TextMatrix(.Rows - 1, 2) = Trim(mrcstudent.Fields(0))
.TextMatrix(.Rows - 1, 3) = Trim(mrcstudent.Fields(7))
.TextMatrix(.Rows - 1, 4) = Trim(mrcstudent.Fields(4))
.TextMatrix(.Rows - 1, 5) = Trim(mrcstudent.Fields(5))
.TextMatrix(.Rows - 1, 6) = Trim(mrcstudent.Fields(6))
.TextMatrix(.Rows - 1, 7) = Trim(mrcstudent.Fields(3))
.TextMatrix(.Rows - 1, 8) = Trim(mrcstudent.Fields(10))
.TextMatrix(.Rows - 1, 9) = Trim(mrcstudent.Fields(14))
.TextMatrix(.Rows - 1, 10) = Trim(mrcstudent.Fields(8))
.TextMatrix(.Rows - 1, 11) = Trim(mrcstudent.Fields(12))
.TextMatrix(.Rows - 1, 12) = Trim(mrcstudent.Fields(13))
mrcstudent.MoveNext
Loop
mrcstudent.Close
End With
End If
End If
Else
If comboFieldName1.Text = "性别" Then
If comboSEX1.Text = "" Then
MsgBox "请选择性别!", vbOKOnly + vbExclamation, "警告"
comboSEX1.SetFocus
Exit Sub
Else
studentSQL = studentSQL & " " & Field(Trim(comboFieldName1.Text)) & " " & Trim(comboChar1.Text) & "'" & Trim(comboSEX1.Text) & "'"
Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)
If mrcstudent.EOF = True Then
MSHFlexGrid.Clear
With MSHFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "卡号"
.TextMatrix(0, 3) = "金额"
.TextMatrix(0, 4) = "系别"
.TextMatrix(0, 5) = "年级"
.TextMatrix(0, 6) = "班级"
.TextMatrix(0, 7) = "性别"
.TextMatrix(0, 8) = "状态"
.TextMatrix(0, 9) = "类型"
.TextMatrix(0, 10) = "备注"
.TextMatrix(0, 11) = "日期"
.TextMatrix(0, 12) = "时间"
End With
MsgBox "该条件数据不存在!", vbOKOnly + vbInformation, "提示"
comboFieldName1.SetFocus
Exit Sub
Else
With MSHFlexGrid
.Rows = 1
Do While mrcstudent.EOF = False
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrcstudent.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrcstudent.Fields(2))
.TextMatrix(.Rows - 1, 2) = Trim(mrcstudent.Fields(0))
.TextMatrix(.Rows - 1, 3) = Trim(mrcstudent.Fields(7))
.TextMatrix(.Rows - 1, 4) = Trim(mrcstudent.Fields(4))
.TextMatrix(.Rows - 1, 5) = Trim(mrcstudent.Fields(5))
.TextMatrix(.Rows - 1, 6) = Trim(mrcstudent.Fields(6))
.TextMatrix(.Rows - 1, 7) = Trim(mrcstudent.Fields(3))
.TextMatrix(.Rows - 1, 8) = Trim(mrcstudent.Fields(10))
.TextMatrix(.Rows - 1, 9) = Trim(mrcstudent.Fields(14))
.TextMatrix(.Rows - 1, 10) = Trim(mrcstudent.Fields(8))
.TextMatrix(.Rows - 1, 11) = Trim(mrcstudent.Fields(12))
.TextMatrix(.Rows - 1, 12) = Trim(mrcstudent.Fields(13))
mrcstudent.MoveNext
Loop
mrcstudent.Close
End With
End If
End If
End If
End If
End Sub
2)二层查询
Public Sub TwoInquery()
'对student_info表操作
Dim mrcstudent As ADODB.Recordset '用于存放记录集
Dim studentSQL As String '用于存放SQL语句
Dim studentMsgText As String '用于存放返回信息
studentSQL = "select * from student_info where"
If comboFieldName1.Text = "姓名" Or comboFieldName1.Text = "系别" Or comboFieldName1.Text = "年级" Or comboFieldName1.Text = "班级" _
Or comboFieldName1.Text = "卡号" Or comboFieldName1.Text = "学号" Then
If txtInquery1.Text = "" Then
MsgBox "请输入查询内容!", vbOKOnly + vbExclamation, "警告"
txtInquery1.SetFocus
Exit Sub
Else
If comboFieldName2.Text = "姓名" Or comboFieldName2.Text = "系别" Or comboFieldName2.Text = "年级" Or comboFieldName2.Text = "班级" _
Or comboFieldName2.Text = "卡号" Or comboFieldName2.Text = "学号" Then
If txtInquery2.Text = "" Then
MsgBox "请输入查询内容!", vbOKOnly + vbExclamation, "警告"
txtInquery2.SetFocus
Exit Sub
Else
studentSQL = studentSQL & " " & Field(Trim(comboFieldName1.Text)) & " " & Trim(comboChar1.Text) & "'" & _
Trim(txtInquery1.Text) & "'" & " " & Trim(comboGroup1.Text) & " " & _
Field(Trim(comboFieldName2.Text)) & " " & Trim(comboChar2.Text) & "'" & _
Trim(txtInquery2.Text) & "'"
Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)
If mrcstudent.EOF = True Then
MSHFlexGrid.Clear
With MSHFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "卡号"
.TextMatrix(0, 3) = "金额"
.TextMatrix(0, 4) = "系别"
.TextMatrix(0, 5) = "年级"
.TextMatrix(0, 6) = "班级"
.TextMatrix(0, 7) = "性别"
.TextMatrix(0, 8) = "状态"
.TextMatrix(0, 9) = "类型"
.TextMatrix(0, 10) = "备注"
.TextMatrix(0, 11) = "日期"
.TextMatrix(0, 12) = "时间"
End With
MsgBox "该条件数据不存在!", vbOKOnly + vbInformation, "提示"
comboFieldName1.SetFocus
Exit Sub
Else
With MSHFlexGrid
.Rows = 1
Do While mrcstudent.EOF = False
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrcstudent.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrcstudent.Fields(2))
.TextMatrix(.Rows - 1, 2) = Trim(mrcstudent.Fields(0))
.TextMatrix(.Rows - 1, 3) = Trim(mrcstudent.Fields(7))
.TextMatrix(.Rows - 1, 4) = Trim(mrcstudent.Fields(4))
.TextMatrix(.Rows - 1, 5) = Trim(mrcstudent.Fields(5))
.TextMatrix(.Rows - 1, 6) = Trim(mrcstudent.Fields(6))
.TextMatrix(.Rows - 1, 7) = Trim(mrcstudent.Fields(3))
.TextMatrix(.Rows - 1, 8) = Trim(mrcstudent.Fields(10))
.TextMatrix(.Rows - 1, 9) = Trim(mrcstudent.Fields(14))
.TextMatrix(.Rows - 1, 10) = Trim(mrcstudent.Fields(8))
.TextMatrix(.Rows - 1, 11) = Trim(mrcstudent.Fields(12))
.TextMatrix(.Rows - 1, 12) = Trim(mrcstudent.Fields(13))
mrcstudent.MoveNext
Loop
mrcstudent.Close
End With
End If
End If
Else
If comboFieldName2.Text = "性别" Then
If comboSEX2.Text = "" Then
MsgBox "请选择性别!", vbOKOnly + vbExclamation, "警告"
comboSEX2.SetFocus
Exit Sub
Else
studentSQL = studentSQL & " " & Field(Trim(comboFieldName1.Text)) & " " & Trim(comboChar1.Text) & "'" & _
Trim(txtInquery1.Text) & "'" & " " & Trim(comboGroup1.Text) & " " & _
Field(Trim(comboFieldName2.Text)) & " " & Trim(comboChar2.Text) & "'" & _
Trim(comboSEX2.Text) & "'"
Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)
If mrcstudent.EOF = True Then
MSHFlexGrid.Clear
With MSHFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "卡号"
.TextMatrix(0, 3) = "金额"
.TextMatrix(0, 4) = "系别"
.TextMatrix(0, 5) = "年级"
.TextMatrix(0, 6) = "班级"
.TextMatrix(0, 7) = "性别"
.TextMatrix(0, 8) = "状态"
.TextMatrix(0, 9) = "类型"
.TextMatrix(0, 10) = "备注"
.TextMatrix(0, 11) = "日期"
.TextMatrix(0, 12) = "时间"
End With
MsgBox "该条件数据不存在!", vbOKOnly + vbInformation, "提示"
comboFieldName1.SetFocus
Exit Sub
Else
With MSHFlexGrid
.Rows = 1
Do While mrcstudent.EOF = False
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrcstudent.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrcstudent.Fields(2))
.TextMatrix(.Rows - 1, 2) = Trim(mrcstudent.Fields(0))
.TextMatrix(.Rows - 1, 3) = Trim(mrcstudent.Fields(7))
.TextMatrix(.Rows - 1, 4) = Trim(mrcstudent.Fields(4))
.TextMatrix(.Rows - 1, 5) = Trim(mrcstudent.Fields(5))
.TextMatrix(.Rows - 1, 6) = Trim(mrcstudent.Fields(6))
.TextMatrix(.Rows - 1, 7) = Trim(mrcstudent.Fields(3))
.TextMatrix(.Rows - 1, 8) = Trim(mrcstudent.Fields(10))
.TextMatrix(.Rows - 1, 9) = Trim(mrcstudent.Fields(14))
.TextMatrix(.Rows - 1, 10) = Trim(mrcstudent.Fields(8))
.TextMatrix(.Rows - 1, 11) = Trim(mrcstudent.Fields(12))
.TextMatrix(.Rows - 1, 12) = Trim(mrcstudent.Fields(13))
mrcstudent.MoveNext
Loop
mrcstudent.Close
End With
End If
End If
End If
End If
End If
Else
If comboFieldName1.Text = "性别" Then
If comboSEX1.Text = "" Then
MsgBox "请选择性别!", vbOKOnly + vbExclamation, "警告"
comboSEX1.SetFocus
Exit Sub
Else
If comboFieldName2.Text = "姓名" Or comboFieldName2.Text = "系别" Or comboFieldName2.Text = "年级" Or comboFieldName2.Text = "班级" _
Or comboFieldName2.Text = "卡号" Or comboFieldName2.Text = "学号" Then
If txtInquery2.Text = "" Then
MsgBox "请输入查询内容!", vbOKOnly + vbExclamation, "警告"
txtInquery2.SetFocus
Exit Sub
Else
studentSQL = studentSQL & " " & Field(Trim(comboFieldName1.Text)) & " " & Trim(comboChar1.Text) & "'" & _
Trim(comboSEX1.Text) & "'" & " " & Trim(comboGroup1.Text) & " " & _
Field(Trim(comboFieldName2.Text)) & " " & Trim(comboChar2.Text) & "'" & _
Trim(txtInquery2.Text) & "'"
Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)
If mrcstudent.EOF = True Then
MSHFlexGrid.Clear
With MSHFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "卡号"
.TextMatrix(0, 3) = "金额"
.TextMatrix(0, 4) = "系别"
.TextMatrix(0, 5) = "年级"
.TextMatrix(0, 6) = "班级"
.TextMatrix(0, 7) = "性别"
.TextMatrix(0, 8) = "状态"
.TextMatrix(0, 9) = "类型"
.TextMatrix(0, 10) = "备注"
.TextMatrix(0, 11) = "日期"
.TextMatrix(0, 12) = "时间"
End With
MsgBox "该条件数据不存在!", vbOKOnly + vbInformation, "提示"
comboFieldName1.SetFocus
Exit Sub
Else
With MSHFlexGrid
.Rows = 1
Do While mrcstudent.EOF = False
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrcstudent.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrcstudent.Fields(2))
.TextMatrix(.Rows - 1, 2) = Trim(mrcstudent.Fields(0))
.TextMatrix(.Rows - 1, 3) = Trim(mrcstudent.Fields(7))
.TextMatrix(.Rows - 1, 4) = Trim(mrcstudent.Fields(4))
.TextMatrix(.Rows - 1, 5) = Trim(mrcstudent.Fields(5))
.TextMatrix(.Rows - 1, 6) = Trim(mrcstudent.Fields(6))
.TextMatrix(.Rows - 1, 7) = Trim(mrcstudent.Fields(3))
.TextMatrix(.Rows - 1, 8) = Trim(mrcstudent.Fields(10))
.TextMatrix(.Rows - 1, 9) = Trim(mrcstudent.Fields(14))
.TextMatrix(.Rows - 1, 10) = Trim(mrcstudent.Fields(8))
.TextMatrix(.Rows - 1, 11) = Trim(mrcstudent.Fields(12))
.TextMatrix(.Rows - 1, 12) = Trim(mrcstudent.Fields(13))
mrcstudent.MoveNext
Loop
mrcstudent.Close
End With
End If
End If
Else
If comboFieldName2.Text = "性别" Then
If comboSEX2.Text = "" Then
MsgBox "请选择性别!", vbOKOnly + vbExclamation, "警告"
comboSEX2.SetFocus
Exit Sub
Else
studentSQL = studentSQL & " " & Field(Trim(comboFieldName1.Text)) & " " & Trim(comboChar1.Text) & "'" & _
Trim(comboSEX1.Text) & "'" & " " & Trim(comboGroup1.Text) & " " & _
Field(Trim(comboFieldName2.Text)) & " " & Trim(comboChar2.Text) & "'" & _
Trim(comboSEX2.Text) & "'"
Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)
If mrcstudent.EOF = True Then
MSHFlexGrid.Clear
With MSHFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "卡号"
.TextMatrix(0, 3) = "金额"
.TextMatrix(0, 4) = "系别"
.TextMatrix(0, 5) = "年级"
.TextMatrix(0, 6) = "班级"
.TextMatrix(0, 7) = "性别"
.TextMatrix(0, 8) = "状态"
.TextMatrix(0, 9) = "类型"
.TextMatrix(0, 10) = "备注"
.TextMatrix(0, 11) = "日期"
.TextMatrix(0, 12) = "时间"
End With
MsgBox "该条件数据不存在!", vbOKOnly + vbInformation, "提示"
comboFieldName1.SetFocus
Exit Sub
Else
With MSHFlexGrid
.Rows = 1
Do While mrcstudent.EOF = False
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrcstudent.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrcstudent.Fields(2))
.TextMatrix(.Rows - 1, 2) = Trim(mrcstudent.Fields(0))
.TextMatrix(.Rows - 1, 3) = Trim(mrcstudent.Fields(7))
.TextMatrix(.Rows - 1, 4) = Trim(mrcstudent.Fields(4))
.TextMatrix(.Rows - 1, 5) = Trim(mrcstudent.Fields(5))
.TextMatrix(.Rows - 1, 6) = Trim(mrcstudent.Fields(6))
.TextMatrix(.Rows - 1, 7) = Trim(mrcstudent.Fields(3))
.TextMatrix(.Rows - 1, 8) = Trim(mrcstudent.Fields(10))
.TextMatrix(.Rows - 1, 9) = Trim(mrcstudent.Fields(14))
.TextMatrix(.Rows - 1, 10) = Trim(mrcstudent.Fields(8))
.TextMatrix(.Rows - 1, 11) = Trim(mrcstudent.Fields(12))
.TextMatrix(.Rows - 1, 12) = Trim(mrcstudent.Fields(13))
mrcstudent.MoveNext
Loop
mrcstudent.Close
End With
End If
End If
End If
End If
End If
End If
End If
End Sub
3)三层查询
Public Sub ThreeInquery()
'对student_info表操作
Dim mrcstudent As ADODB.Recordset '用于存放记录集
Dim studentSQL As String '用于存放SQL语句
Dim studentMsgText As String '用于存放返回信息
studentSQL = "select * from student_info where"
If comboFieldName1.Text = "姓名" Or comboFieldName1.Text = "系别" Or comboFieldName1.Text = "年级" Or comboFieldName1.Text = "班级" _
Or comboFieldName1.Text = "卡号" Or comboFieldName1.Text = "学号" Then
If txtInquery1.Text = "" Then
MsgBox "请输入查询内容!", vbOKOnly + vbExclamation, "警告"
txtInquery1.SetFocus
Exit Sub
Else
If comboFieldName2.Text = "姓名" Or comboFieldName2.Text = "系别" Or comboFieldName2.Text = "年级" Or comboFieldName2.Text = "班级" _
Or comboFieldName2.Text = "卡号" Or comboFieldName2.Text = "学号" Then
If txtInquery2.Text = "" Then
MsgBox "请输入查询内容!", vbOKOnly + vbExclamation, "警告"
txtInquery2.SetFocus
Exit Sub
Else
If comboFieldName3.Text = "姓名" Or comboFieldName3.Text = "系别" Or comboFieldName3.Text = "年级" Or comboFieldName3.Text = "班级" _
Or comboFieldName3.Text = "卡号" Or comboFieldName3.Text = "学号" Then
If txtInquery3.Text = "" Then
MsgBox "请输入查询内容!", vbOKOnly + vbExclamation, "警告"
txtInquery3.SetFocus
Exit Sub
Else
studentSQL = studentSQL & " " & Field(Trim(comboFieldName1.Text)) & " " & Trim(comboChar1.Text) & "'" & _
Trim(txtInquery1.Text) & "'" & " " & Trim(comboGroup1.Text) & " " & _
Field(Trim(comboFieldName2.Text)) & " " & Trim(comboChar2.Text) & "'" & _
Trim(txtInquery2.Text) & "'" & " " & Trim(comboGroup2.Text) & " " & Field(Trim(comboFieldName3.Text)) & _
" " & Trim(comboChar3.Text) & "'" & Trim(txtInquery3.Text) & "'"
Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)
If mrcstudent.EOF = True Then
MSHFlexGrid.Clear
With MSHFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "卡号"
.TextMatrix(0, 3) = "金额"
.TextMatrix(0, 4) = "系别"
.TextMatrix(0, 5) = "年级"
.TextMatrix(0, 6) = "班级"
.TextMatrix(0, 7) = "性别"
.TextMatrix(0, 8) = "状态"
.TextMatrix(0, 9) = "类型"
.TextMatrix(0, 10) = "备注"
.TextMatrix(0, 11) = "日期"
.TextMatrix(0, 12) = "时间"
End With
MsgBox "该条件数据不存在!", vbOKOnly + vbInformation, "提示"
comboFieldName1.SetFocus
Exit Sub
Else
With MSHFlexGrid
.Rows = 1
Do While mrcstudent.EOF = False
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrcstudent.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrcstudent.Fields(2))
.TextMatrix(.Rows - 1, 2) = Trim(mrcstudent.Fields(0))
.TextMatrix(.Rows - 1, 3) = Trim(mrcstudent.Fields(7))
.TextMatrix(.Rows - 1, 4) = Trim(mrcstudent.Fields(4))
.TextMatrix(.Rows - 1, 5) = Trim(mrcstudent.Fields(5))
.TextMatrix(.Rows - 1, 6) = Trim(mrcstudent.Fields(6))
.TextMatrix(.Rows - 1, 7) = Trim(mrcstudent.Fields(3))
.TextMatrix(.Rows - 1, 8) = Trim(mrcstudent.Fields(10))
.TextMatrix(.Rows - 1, 9) = Trim(mrcstudent.Fields(14))
.TextMatrix(.Rows - 1, 10) = Trim(mrcstudent.Fields(8))
.TextMatrix(.Rows - 1, 11) = Trim(mrcstudent.Fields(12))
.TextMatrix(.Rows - 1, 12) = Trim(mrcstudent.Fields(13))
mrcstudent.MoveNext
Loop
mrcstudent.Close
End With
End If
End If
Else
If comboFieldName3.Text = "性别" Then
If comboSEX3.Text = "" Then
MsgBox "请输入查询内容!", vbOKOnly + vbExclamation, "警告"
comboSEX3.SetFocus
Exit Sub
Else
studentSQL = studentSQL & " " & Field(Trim(comboFieldName1.Text)) & " " & Trim(comboChar1.Text) & "'" & _
Trim(txtInquery1.Text) & "'" & " " & Trim(comboGroup1.Text) & " " & _
Field(Trim(comboFieldName2.Text)) & " " & Trim(comboChar2.Text) & "'" & _
Trim(txtInquery2.Text) & "'" & " " & Trim(comboGroup2.Text) & " " & Field(Trim(comboFieldName3.Text)) & _
" " & Trim(comboChar3.Text) & "'" & Trim(comboSEX3.Text) & "'"
Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)
If mrcstudent.EOF = True Then
MSHFlexGrid.Clear
With MSHFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "卡号"
.TextMatrix(0, 3) = "金额"
.TextMatrix(0, 4) = "系别"
.TextMatrix(0, 5) = "年级"
.TextMatrix(0, 6) = "班级"
.TextMatrix(0, 7) = "性别"
.TextMatrix(0, 8) = "状态"
.TextMatrix(0, 9) = "类型"
.TextMatrix(0, 10) = "备注"
.TextMatrix(0, 11) = "日期"
.TextMatrix(0, 12) = "时间"
End With
MsgBox "该条件数据不存在!", vbOKOnly + vbInformation, "提示"
comboFieldName1.SetFocus
Exit Sub
Else
With MSHFlexGrid
.Rows = 1
Do While mrcstudent.EOF = False
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrcstudent.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrcstudent.Fields(2))
.TextMatrix(.Rows - 1, 2) = Trim(mrcstudent.Fields(0))
.TextMatrix(.Rows - 1, 3) = Trim(mrcstudent.Fields(7))
.TextMatrix(.Rows - 1, 4) = Trim(mrcstudent.Fields(4))
.TextMatrix(.Rows - 1, 5) = Trim(mrcstudent.Fields(5))
.TextMatrix(.Rows - 1, 6) = Trim(mrcstudent.Fields(6))
.TextMatrix(.Rows - 1, 7) = Trim(mrcstudent.Fields(3))
.TextMatrix(.Rows - 1, 8) = Trim(mrcstudent.Fields(10))
.TextMatrix(.Rows - 1, 9) = Trim(mrcstudent.Fields(14))
.TextMatrix(.Rows - 1, 10) = Trim(mrcstudent.Fields(8))
.TextMatrix(.Rows - 1, 11) = Trim(mrcstudent.Fields(12))
.TextMatrix(.Rows - 1, 12) = Trim(mrcstudent.Fields(13))
mrcstudent.MoveNext
Loop
mrcstudent.Close
End With
End If
End If
End If
End If
End If
Else
If comboFieldName2.Text = "性别" Then
If comboSEX2.Text = "" Then
MsgBox "请选择性别!", vbOKOnly + vbExclamation, "警告"
comboSEX2.SetFocus
Exit Sub
Else
If comboFieldName3.Text = "姓名" Or comboFieldName3.Text = "系别" Or comboFieldName3.Text = "年级" Or comboFieldName3.Text = "班级" _
Or comboFieldName3.Text = "卡号" Or comboFieldName3.Text = "学号" Then
If txtInquery3.Text = "" Then
MsgBox "请输入查询内容!", vbOKOnly + vbExclamation, "警告"
txtInquery3.SetFocus
Exit Sub
Else
studentSQL = studentSQL & " " & Field(Trim(comboFieldName1.Text)) & " " & Trim(comboChar1.Text) & "'" & _
Trim(txtInquery1.Text) & "'" & " " & Trim(comboGroup1.Text) & " " & _
Field(Trim(comboFieldName2.Text)) & " " & Trim(comboChar2.Text) & "'" & _
Trim(comboSEX2.Text) & "'" & " " & Trim(comboGroup2.Text) & " " & Field(Trim(comboFieldName3.Text)) & _
" " & Trim(comboChar3.Text) & "'" & Trim(txtInquery3.Text) & "'"
Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)
If mrcstudent.EOF = True Then
MSHFlexGrid.Clear
With MSHFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "卡号"
.TextMatrix(0, 3) = "金额"
.TextMatrix(0, 4) = "系别"
.TextMatrix(0, 5) = "年级"
.TextMatrix(0, 6) = "班级"
.TextMatrix(0, 7) = "性别"
.TextMatrix(0, 8) = "状态"
.TextMatrix(0, 9) = "类型"
.TextMatrix(0, 10) = "备注"
.TextMatrix(0, 11) = "日期"
.TextMatrix(0, 12) = "时间"
End With
MsgBox "该条件数据不存在!", vbOKOnly + vbInformation, "提示"
comboFieldName1.SetFocus
Exit Sub
Else
With MSHFlexGrid
.Rows = 1
Do While mrcstudent.EOF = False
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrcstudent.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrcstudent.Fields(2))
.TextMatrix(.Rows - 1, 2) = Trim(mrcstudent.Fields(0))
.TextMatrix(.Rows - 1, 3) = Trim(mrcstudent.Fields(7))
.TextMatrix(.Rows - 1, 4) = Trim(mrcstudent.Fields(4))
.TextMatrix(.Rows - 1, 5) = Trim(mrcstudent.Fields(5))
.TextMatrix(.Rows - 1, 6) = Trim(mrcstudent.Fields(6))
.TextMatrix(.Rows - 1, 7) = Trim(mrcstudent.Fields(3))
.TextMatrix(.Rows - 1, 8) = Trim(mrcstudent.Fields(10))
.TextMatrix(.Rows - 1, 9) = Trim(mrcstudent.Fields(14))
.TextMatrix(.Rows - 1, 10) = Trim(mrcstudent.Fields(8))
.TextMatrix(.Rows - 1, 11) = Trim(mrcstudent.Fields(12))
.TextMatrix(.Rows - 1, 12) = Trim(mrcstudent.Fields(13))
mrcstudent.MoveNext
Loop
mrcstudent.Close
End With
End If
End If
Else
If comboFieldName3.Text = "性别" Then
If comboSEX3.Text = "" Then
MsgBox "请输入查询内容!", vbOKOnly + vbExclamation, "警告"
comboSEX3.SetFocus
Exit Sub
Else
studentSQL = studentSQL & " " & Field(Trim(comboFieldName1.Text)) & " " & Trim(comboChar1.Text) & "'" & _
Trim(txtInquery1.Text) & "'" & " " & Trim(comboGroup1.Text) & " " & _
Field(Trim(comboFieldName2.Text)) & " " & Trim(comboChar2.Text) & "'" & _
Trim(comboSEX2.Text) & "'" & " " & Trim(comboGroup2.Text) & " " & Field(Trim(comboFieldName3.Text)) & _
" " & Trim(comboChar3.Text) & "'" & Trim(comboSEX3.Text) & "'"
Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)
If mrcstudent.EOF = True Then
MSHFlexGrid.Clear
With MSHFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "卡号"
.TextMatrix(0, 3) = "金额"
.TextMatrix(0, 4) = "系别"
.TextMatrix(0, 5) = "年级"
.TextMatrix(0, 6) = "班级"
.TextMatrix(0, 7) = "性别"
.TextMatrix(0, 8) = "状态"
.TextMatrix(0, 9) = "类型"
.TextMatrix(0, 10) = "备注"
.TextMatrix(0, 11) = "日期"
.TextMatrix(0, 12) = "时间"
End With
MsgBox "该条件数据不存在!", vbOKOnly + vbInformation, "提示"
comboFieldName1.SetFocus
Exit Sub
Else
With MSHFlexGrid
.Rows = 1
Do While mrcstudent.EOF = False
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrcstudent.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrcstudent.Fields(2))
.TextMatrix(.Rows - 1, 2) = Trim(mrcstudent.Fields(0))
.TextMatrix(.Rows - 1, 3) = Trim(mrcstudent.Fields(7))
.TextMatrix(.Rows - 1, 4) = Trim(mrcstudent.Fields(4))
.TextMatrix(.Rows - 1, 5) = Trim(mrcstudent.Fields(5))
.TextMatrix(.Rows - 1, 6) = Trim(mrcstudent.Fields(6))
.TextMatrix(.Rows - 1, 7) = Trim(mrcstudent.Fields(3))
.TextMatrix(.Rows - 1, 8) = Trim(mrcstudent.Fields(10))
.TextMatrix(.Rows - 1, 9) = Trim(mrcstudent.Fields(14))
.TextMatrix(.Rows - 1, 10) = Trim(mrcstudent.Fields(8))
.TextMatrix(.Rows - 1, 11) = Trim(mrcstudent.Fields(12))
.TextMatrix(.Rows - 1, 12) = Trim(mrcstudent.Fields(13))
mrcstudent.MoveNext
Loop
mrcstudent.Close
End With
End If
End If
End If
End If
End If
End If
End If
End If
Else
If comboFieldName1.Text = "性别" Then
If comboSEX1.Text = "" Then
MsgBox "请选择性别!", vbOKOnly + vbExclamation, "警告"
comboSEX1.SetFocus
Exit Sub
Else
If comboFieldName2.Text = "姓名" Or comboFieldName2.Text = "系别" Or comboFieldName2.Text = "年级" Or comboFieldName2.Text = "班级" _
Or comboFieldName2.Text = "卡号" Or comboFieldName2.Text = "学号" Then
If txtInquery2.Text = "" Then
MsgBox "请输入查询内容!", vbOKOnly + vbExclamation, "警告"
txtInquery2.SetFocus
Exit Sub
Else
If comboFieldName3.Text = "姓名" Or comboFieldName3.Text = "系别" Or comboFieldName3.Text = "年级" Or comboFieldName3.Text = "班级" _
Or comboFieldName3.Text = "卡号" Or comboFieldName3.Text = "学号" Then
If txtInquery3.Text = "" Then
MsgBox "请输入查询内容!", vbOKOnly + vbExclamation, "警告"
txtInquery3.SetFocus
Exit Sub
Else
studentSQL = studentSQL & " " & Field(Trim(comboFieldName1.Text)) & " " & Trim(comboChar1.Text) & "'" & _
Trim(comboSEX1.Text) & "'" & " " & Trim(comboGroup1.Text) & " " & _
Field(Trim(comboFieldName2.Text)) & " " & Trim(comboChar2.Text) & "'" & _
Trim(txtInquery2.Text) & "'" & " " & Trim(comboGroup2.Text) & " " & Field(Trim(comboFieldName3.Text)) & _
" " & Trim(comboChar3.Text) & "'" & Trim(txtInquery3.Text) & "'"
Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)
If mrcstudent.EOF = True Then
MSHFlexGrid.Clear
With MSHFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "卡号"
.TextMatrix(0, 3) = "金额"
.TextMatrix(0, 4) = "系别"
.TextMatrix(0, 5) = "年级"
.TextMatrix(0, 6) = "班级"
.TextMatrix(0, 7) = "性别"
.TextMatrix(0, 8) = "状态"
.TextMatrix(0, 9) = "类型"
.TextMatrix(0, 10) = "备注"
.TextMatrix(0, 11) = "日期"
.TextMatrix(0, 12) = "时间"
End With
MsgBox "该条件数据不存在!", vbOKOnly + vbInformation, "提示"
comboFieldName1.SetFocus
Exit Sub
Else
With MSHFlexGrid
.Rows = 1
Do While mrcstudent.EOF = False
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrcstudent.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrcstudent.Fields(2))
.TextMatrix(.Rows - 1, 2) = Trim(mrcstudent.Fields(0))
.TextMatrix(.Rows - 1, 3) = Trim(mrcstudent.Fields(7))
.TextMatrix(.Rows - 1, 4) = Trim(mrcstudent.Fields(4))
.TextMatrix(.Rows - 1, 5) = Trim(mrcstudent.Fields(5))
.TextMatrix(.Rows - 1, 6) = Trim(mrcstudent.Fields(6))
.TextMatrix(.Rows - 1, 7) = Trim(mrcstudent.Fields(3))
.TextMatrix(.Rows - 1, 8) = Trim(mrcstudent.Fields(10))
.TextMatrix(.Rows - 1, 9) = Trim(mrcstudent.Fields(14))
.TextMatrix(.Rows - 1, 10) = Trim(mrcstudent.Fields(8))
.TextMatrix(.Rows - 1, 11) = Trim(mrcstudent.Fields(12))
.TextMatrix(.Rows - 1, 12) = Trim(mrcstudent.Fields(13))
mrcstudent.MoveNext
Loop
mrcstudent.Close
End With
End If
End If
Else
If comboFieldName3.Text = "性别" Then
If comboSEX3.Text = "" Then
MsgBox "请输入查询内容!", vbOKOnly + vbExclamation, "警告"
comboSEX3.SetFocus
Exit Sub
Else
studentSQL = studentSQL & " " & Field(Trim(comboFieldName1.Text)) & " " & Trim(comboChar1.Text) & "'" & _
Trim(comboSEX1.Text) & "'" & " " & Trim(comboGroup1.Text) & " " & _
Field(Trim(comboFieldName2.Text)) & " " & Trim(comboChar2.Text) & "'" & _
Trim(txtInquery2.Text) & "'" & " " & Trim(comboGroup2.Text) & " " & Field(Trim(comboFieldName3.Text)) & _
" " & Trim(comboChar3.Text) & "'" & Trim(comboSEX3.Text) & "'"
Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)
If mrcstudent.EOF = True Then
MSHFlexGrid.Clear
With MSHFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "卡号"
.TextMatrix(0, 3) = "金额"
.TextMatrix(0, 4) = "系别"
.TextMatrix(0, 5) = "年级"
.TextMatrix(0, 6) = "班级"
.TextMatrix(0, 7) = "性别"
.TextMatrix(0, 8) = "状态"
.TextMatrix(0, 9) = "类型"
.TextMatrix(0, 10) = "备注"
.TextMatrix(0, 11) = "日期"
.TextMatrix(0, 12) = "时间"
End With
MsgBox "该条件数据不存在!", vbOKOnly + vbInformation, "提示"
comboFieldName1.SetFocus
Exit Sub
Else
With MSHFlexGrid
.Rows = 1
Do While mrcstudent.EOF = False
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrcstudent.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrcstudent.Fields(2))
.TextMatrix(.Rows - 1, 2) = Trim(mrcstudent.Fields(0))
.TextMatrix(.Rows - 1, 3) = Trim(mrcstudent.Fields(7))
.TextMatrix(.Rows - 1, 4) = Trim(mrcstudent.Fields(4))
.TextMatrix(.Rows - 1, 5) = Trim(mrcstudent.Fields(5))
.TextMatrix(.Rows - 1, 6) = Trim(mrcstudent.Fields(6))
.TextMatrix(.Rows - 1, 7) = Trim(mrcstudent.Fields(3))
.TextMatrix(.Rows - 1, 8) = Trim(mrcstudent.Fields(10))
.TextMatrix(.Rows - 1, 9) = Trim(mrcstudent.Fields(14))
.TextMatrix(.Rows - 1, 10) = Trim(mrcstudent.Fields(8))
.TextMatrix(.Rows - 1, 11) = Trim(mrcstudent.Fields(12))
.TextMatrix(.Rows - 1, 12) = Trim(mrcstudent.Fields(13))
mrcstudent.MoveNext
Loop
mrcstudent.Close
End With
End If
End If
End If
End If
End If
Else
If comboFieldName2.Text = "性别" Then
If comboSEX2.Text = "" Then
MsgBox "请选择性别!", vbOKOnly + vbExclamation, "警告"
comboSEX2.SetFocus
Exit Sub
Else
If comboFieldName3.Text = "姓名" Or comboFieldName3.Text = "系别" Or comboFieldName3.Text = "年级" Or comboFieldName3.Text = "班级" _
Or comboFieldName3.Text = "卡号" Or comboFieldName3.Text = "学号" Then
If txtInquery3.Text = "" Then
MsgBox "请输入查询内容!", vbOKOnly + vbExclamation, "警告"
txtInquery3.SetFocus
Exit Sub
Else
studentSQL = studentSQL & " " & Field(Trim(comboFieldName1.Text)) & " " & Trim(comboChar1.Text) & "'" & _
Trim(comboSEX1.Text) & "'" & " " & Trim(comboGroup1.Text) & " " & _
Field(Trim(comboFieldName2.Text)) & " " & Trim(comboChar2.Text) & "'" & _
Trim(comboSEX2.Text) & "'" & " " & Trim(comboGroup2.Text) & " " & Field(Trim(comboFieldName3.Text)) & _
" " & Trim(comboChar3.Text) & "'" & Trim(txtInquery3.Text) & "'"
Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)
If mrcstudent.EOF = True Then
MSHFlexGrid.Clear
With MSHFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "卡号"
.TextMatrix(0, 3) = "金额"
.TextMatrix(0, 4) = "系别"
.TextMatrix(0, 5) = "年级"
.TextMatrix(0, 6) = "班级"
.TextMatrix(0, 7) = "性别"
.TextMatrix(0, 8) = "状态"
.TextMatrix(0, 9) = "类型"
.TextMatrix(0, 10) = "备注"
.TextMatrix(0, 11) = "日期"
.TextMatrix(0, 12) = "时间"
End With
MsgBox "该条件数据不存在!", vbOKOnly + vbInformation, "提示"
comboFieldName1.SetFocus
Exit Sub
Else
With MSHFlexGrid
.Rows = 1
Do While mrcstudent.EOF = False
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrcstudent.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrcstudent.Fields(2))
.TextMatrix(.Rows - 1, 2) = Trim(mrcstudent.Fields(0))
.TextMatrix(.Rows - 1, 3) = Trim(mrcstudent.Fields(7))
.TextMatrix(.Rows - 1, 4) = Trim(mrcstudent.Fields(4))
.TextMatrix(.Rows - 1, 5) = Trim(mrcstudent.Fields(5))
.TextMatrix(.Rows - 1, 6) = Trim(mrcstudent.Fields(6))
.TextMatrix(.Rows - 1, 7) = Trim(mrcstudent.Fields(3))
.TextMatrix(.Rows - 1, 8) = Trim(mrcstudent.Fields(10))
.TextMatrix(.Rows - 1, 9) = Trim(mrcstudent.Fields(14))
.TextMatrix(.Rows - 1, 10) = Trim(mrcstudent.Fields(8))
.TextMatrix(.Rows - 1, 11) = Trim(mrcstudent.Fields(12))
.TextMatrix(.Rows - 1, 12) = Trim(mrcstudent.Fields(13))
mrcstudent.MoveNext
Loop
mrcstudent.Close
End With
End If
End If
Else
If comboFieldName3.Text = "性别" Then
If comboSEX3.Text = "" Then
MsgBox "请输入查询内容!", vbOKOnly + vbExclamation, "警告"
comboSEX3.SetFocus
Exit Sub
Else
studentSQL = studentSQL & " " & Field(Trim(comboFieldName1.Text)) & " " & Trim(comboChar1.Text) & "'" & _
Trim(comboSEX1.Text) & "'" & " " & Trim(comboGroup1.Text) & " " & _
Field(Trim(comboFieldName2.Text)) & " " & Trim(comboChar2.Text) & "'" & _
Trim(comboSEX2.Text) & "'" & " " & Trim(comboGroup2.Text) & " " & Field(Trim(comboFieldName3.Text)) & _
" " & Trim(comboChar3.Text) & "'" & Trim(comboSEX3.Text) & "'"
Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)
If mrcstudent.EOF = True Then
MSHFlexGrid.Clear
With MSHFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "卡号"
.TextMatrix(0, 3) = "金额"
.TextMatrix(0, 4) = "系别"
.TextMatrix(0, 5) = "年级"
.TextMatrix(0, 6) = "班级"
.TextMatrix(0, 7) = "性别"
.TextMatrix(0, 8) = "状态"
.TextMatrix(0, 9) = "类型"
.TextMatrix(0, 10) = "备注"
.TextMatrix(0, 11) = "日期"
.TextMatrix(0, 12) = "时间"
End With
MsgBox "该条件数据不存在!", vbOKOnly + vbInformation, "提示"
comboFieldName1.SetFocus
Exit Sub
Else
With MSHFlexGrid
.Rows = 1
Do While mrcstudent.EOF = False
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrcstudent.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrcstudent.Fields(2))
.TextMatrix(.Rows - 1, 2) = Trim(mrcstudent.Fields(0))
.TextMatrix(.Rows - 1, 3) = Trim(mrcstudent.Fields(7))
.TextMatrix(.Rows - 1, 4) = Trim(mrcstudent.Fields(4))
.TextMatrix(.Rows - 1, 5) = Trim(mrcstudent.Fields(5))
.TextMatrix(.Rows - 1, 6) = Trim(mrcstudent.Fields(6))
.TextMatrix(.Rows - 1, 7) = Trim(mrcstudent.Fields(3))
.TextMatrix(.Rows - 1, 8) = Trim(mrcstudent.Fields(10))
.TextMatrix(.Rows - 1, 9) = Trim(mrcstudent.Fields(14))
.TextMatrix(.Rows - 1, 10) = Trim(mrcstudent.Fields(8))
.TextMatrix(.Rows - 1, 11) = Trim(mrcstudent.Fields(12))
.TextMatrix(.Rows - 1, 12) = Trim(mrcstudent.Fields(13))
mrcstudent.MoveNext
Loop
mrcstudent.Close
End With
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
清空所有内容:
Private Sub cmdEmpty_Click()
'清空所有控件内容
comboFieldName1.Text = ""
comboFieldName2.Text = ""
comboFieldName3.Text = ""
comboChar1.Text = ""
comboChar2.Text = ""
comboChar3.Text = ""
txtInquery1.Text = ""
txtInquery2.Text = ""
txtInquery3.Text = ""
comboGroup1.Text = ""
comboGroup2.Text = ""
comboSEX1.Text = ""
comboSEX2.Text = ""
comboSEX3.Text = ""
MSHFlexGrid.Clear
With MSHFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "卡号"
.TextMatrix(0, 3) = "金额"
.TextMatrix(0, 4) = "系别"
.TextMatrix(0, 5) = "年级"
.TextMatrix(0, 6) = "班级"
.TextMatrix(0, 7) = "性别"
.TextMatrix(0, 8) = "状态"
.TextMatrix(0, 9) = "类型"
.TextMatrix(0, 10) = "备注"
.TextMatrix(0, 11) = "日期"
.TextMatrix(0, 12) = "时间"
End With
End Sub