挨个判断就行了,还怎么快速~~ If Check1.Value Then MsgBox "被选中了" [email protected]
一个一个去判断呀 比如: 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
If Check1.Value Then MsgBox "被选中了"
把CHECKBOX做成数组控件吧。这样一个循环就可以判断完了。
'注意各空格以及字段类型是字符的要加单引号,日期要格式化后比较 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
If Check1 Then ......... if check2 then.......... ... 把所有的都列上就好了
check1.value=0表示未选中
If Check1.Value Then MsgBox "被选中了"
[email protected]
比如:
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
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
if check2 then..........
...
把所有的都列上就好了
我也9个CHECK。
代表A类型
B类型
C类型
。
我的方法是建立九个字段,分别对应相应的CHECK
然后直接存取CHECK的值就行了,也就是0与1
这样的话,就一般没什么问题了