我建立了一组check控件,用来进行选择性的查询,不知道怎么来获取那些被选中
,请愿意帮我忙的大哥们给我一个信箱地址我把这个界面发送给你帮我解决一下谢了。请把你的信箱留下我把这个截面发送给你!!!!!

解决方案 »

  1.   

    一个一个去判断呀
    比如:
    Dim strTemp As String
    If check1.Value Then strTemp = strTemp & " [check1被选中] "
    If check2.Value Then strTemp = strTemp & " [check3被选中] "
    If check3.Value Then strTemp = strTemp & " [check3被选中] "
    If check4.Value Then strTemp = strTemp & " [check4被选中] "
    If check5.Value Then strTemp = strTemp & " [check5被选中] "
    If strTemp = "" Then
        MsgBox "选中情况:" & strTemp
    Else
        MsgBox "没有选中的Check"
    End If
      

  2.   

    把CHECKBOX做成数组控件吧。这样一个循环就可以判断完了。
      

  3.   

    Dim Y As New CollectionPrivate Sub Form_Load()
        Dim x As Object
        For Each x In Me.Controls
            If TypeOf x Is CheckBox Then
                If x.Value = 1 Then
                    Y.Add x, x.Name
                End If
            End If
        Next
    End Sub
      

  4.   

    '注意各空格以及字段类型是字符的要加单引号,日期要格式化后比较
    Dim strSql As String
    Dim rs As ADODB.Recordset
    strSql = " Where 1=1 "
    If check品名 Then strSql = strSql + "And 品名='" & txt品名.Text & "' "
    If check数量 Then strSql = strSql + "And 数量=" & txt数量.Text
    If check成交金额 Then strSql = strSql + "And 成交金额=" & txt成交金额.Text
    If check运输方式 Then strSql = strSql + "And 运输方式='" & combo运输方式.Text & "' "
    If check商品编码 Then strSql = strSql + "And 商品编码='" & txt商品编码.Text & "' "
    If check单价 Then strSql = strSql + "And 单价='" & txt单价.Text & "' "
    If check成交方式 Then strSql = strSql + "And 成交方式='" & combo成交方式.Text & "' "
    If check收货人 Then strSql = strSql + "And 收货人='" & 收货人.Text & "' "
    If check规格 Then strSql = strSql + "And 规格='" & 规格.Text & "' "
    If check付款方式 Then strSql = strSql + "And 付款方式='" & 付款方式.Text & "' "
    If check发货人 Then strSql = strSql + "And 发货人='" & 发货人.Text & "' "
    If check日期 Then strSql = strSql + "And 日期 between '" & Format(dtpStart日期.Value, "yyyy-MM-dd") & "' and '" & Format(dtpStart日期.Value, "yyyy-MM-dd") & "'"
    Set rs = New ADODB.Recordset
    rs.Open "select * from 发货信息 " & strSql, cn
    Set msflexgrid1.DataSource = rs
    rs.Close
    Set rs = Nothing