Dim Filter As String
With e.Form.Controls("开始")
If .Value IsNot Nothing Then
Filter = "(记录时间 >= #" & .Value & "#"
End If
End With
With e.Form.Controls("结束")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " and "
End If
Filter = Filter & "记录时间 <= #" & .Value & "#)"
Else
Filter = Filter & ")"
End If
End With
With e.Form.Controls("开始2")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " or "
End If
Filter = Filter & "(记录时间 >= #" & .Value & "#"
End If
End With
With e.Form.Controls("产品类别")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "产品类别 = '" & .Value & "'"
End If
End With
With e.Form.Controls("产品类别2")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " or "
End If
Filter = Filter & "产品类别 = '" & .Value & "'"
End If
End With
With e.Form.Controls("结束2")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " and "
End If
Filter = Filter & "记录时间 <= #" & .Value & "#)"
Else
Filter = Filter & ")"
End If
End With
If Filter > "" Then
Tables("主控窗口_Table2").Filter = Filter
End If 老师是不是一个是and 一个是or 他说我右括号太多了