甜老师您好!安照您的方式我改好后单个控件里可以多选项查询了,但查询的结果又出问题了,改好的代码如下,现在的查询结果是以最后一个查询控件查询的,不能交叉了!
Dim Filter As String
With e.Form.Controls("cmbProduct")
If .Value IsNot Nothing Then
Filter = "地址 in ('" & .Value.Replace(",", "','") & "')"
End If
End With
With e.Form.Controls("cmbCustomer")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = "吃饭 in ('" & .Value.Replace(",", "','") & "')"
End If
End With
With e.Form.Controls("cmbEmployee")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = "车费 in ('" & .Value.Replace(",", "','") & "')"
End If
End With
With e.Form.Controls("StartDate")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "记录日期 >= #" & .Value & "#"
End If
End With
With e.Form.Controls("EndDate")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "记录日期 <= #" & .Value & "#"
End If
End With
If e.Form.Controls("rdoYifu").Checked = True ' 如果付款状态选择了"已付"
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "已记录 = True"
End If
If e.Form.Controls("rdoWeifu").Checked = True ' 如果付款状态选择了"未付"
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "已记录 = False Or 已记录 Is Null"
End If
If Filter > "" Then
Tables("交叉").Filter = Filter
End If