刚刚已经发现了这个问题了,但是又带来筛选语句的另外一个问题:两个复选框只能使用其中一个,第二个复选框生效的时候第一个复选框就失效了。。。
我写的代码是这样的
Dim Filter As String
With e.Form.Controls("CheckedComboBox1")
If .Value IsNot Nothing Then
Filter &= " and 产品种类_产品大类 in ('" & .Text.Replace(",", "','") & "')"
End If
End With
With e.Form.Controls("CheckedComboBox2")
If .Value IsNot Nothing Then
Filter &= " and 供应商 in ('" & .Text.Replace(",", "','") & "')"
End If
End With
With e.Form.Controls("CheckedComboBox3")
If .Value IsNot Nothing Then
Filter &= " and 标记 in ('" & .Text.Replace(",", "','") & "')"
End If
End With
With e.Form.Controls("CheckedComboBox4")
If .Value IsNot Nothing Then
Filter &= " and 品名 in ('" & .Text.Replace(",", "','") & "')"
End If
End With
If e.Form.Controls("CheckBox1").Checked = True
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "库存预警_补货数量 > 0 "
End If
If e.Form.Controls("CheckBox2").Checked = True
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "标记 Not Like '%停止补货%' Or 标记 is Null"
End If
If Filter >"" Then
Tables("查询_采购关联").Filter = Filter
End If
理想的运算结果是
如果CheckBox1和2都勾选,应该是显示 库存预警_补货数量 > 0 同时 标记 Not Like '%停止补货%' Or 标记 is Null 的结果
但是实际上如果勾选了CheckBox2,那CheckBox1的勾选就失效了,显示的结果包含了 存预警_补货数量 > 0、<=0 的情况。。
不知道是代码哪里出了问题,麻烦老师纠正一下。非常感谢!