【机房】-组合查询概要

机房慢慢摇,总结也是需要写一写的,下面介绍一下组合查询


思路:


前三个空为空--第一个组合框--第二个组合--第二个组合框--第三个组合--查询

代码:


   
If Trim(Combrelation1.Text <> "") Then        '选择了第一个组合关系后,第二行不能为空
        If Trim(Combfield2.Text) = "" Or Trim(Comboperator2.Text) = "" Or Trim(txtcontent2.Text) = "" Then
            MsgBox "您选择了组合关系,请输入数据之后再查询", vbExclamation + vbOKOnly, "提示信息"
            Exit Sub
        Else
          txtSQL = txtSQL & FieldName(Combrelation1.Text) & " " & "" & FieldName(Combfield2.Text) & Comboperator2.Text & "'" & Trim(txtcontent2.Text) & "'"
        End If
    End If
    
    If Trim(Combrelation2.Text) <> "" Then '选择了第二个组合关系后,第三行不能为空
        If Trim(Combfield3.Text) = "" Or Trim(Comboperator3.Text) = "" Or Trim(txtcontent3.Text) = "" Then
            MsgBox "您选择了第二个组合,请输入数据之后再查询", vbOKOnly, "提示"
            Exit Sub
        Else
            txtSQL = txtSQL & FieldName(Combrelation2.Text) & " " & "" & FieldName(Combfield3.Text) & Comboperator3.Text & "'" & Trim(txtcontent3.Text) & "'"
        End If
    End If
    '开始进行查找
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    If mrc.RecordCount = 0 Then
       MsgBox "没有您要查找的学生上机记录!", vbOKOnly + vbCritical, "查询提示"
       Combfield1.SetFocus
       MSHFlexGrid1.Rows = 1
        '存在上机记录查询成功,填充到表格
    Else
        With MSHFlexGrid1
            .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) = "时间"
        
            Do While Not mrc.EOF
                .Rows = .Rows + 1
                .TextMatrix(.Rows - 1, 0) = mrc.Fields(1)
                .TextMatrix(.Rows - 1, 1) = mrc.Fields(2)
                .TextMatrix(.Rows - 1, 2) = mrc.Fields(0)
                .TextMatrix(.Rows - 1, 3) = mrc.Fields(7)
                .TextMatrix(.Rows - 1, 4) = mrc.Fields(4) & ""
                .TextMatrix(.Rows - 1, 5) = mrc.Fields(5) & ""
                 .TextMatrix(.Rows - 1, 6) = mrc.Fields(6) & ""
                .TextMatrix(.Rows - 1, 7) = mrc.Fields(3) & ""
                .TextMatrix(.Rows - 1, 8) = mrc.Fields(10) & ""
                .TextMatrix(.Rows - 1, 9) = mrc.Fields(8) & ""
                .TextMatrix(.Rows - 1, 10) = mrc.Fields(14) & ""
                .TextMatrix(.Rows - 1, 11) = mrc.Fields(12) & ""
                .TextMatrix(.Rows - 1, 12) = mrc.Fields(13) & ""
                mrc.MoveNext
            Loop
        End With
 End If

评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值