Dim Filter As String = ""
With RibbonTabs("凭证操作").Groups("收支").Items("开始日期")
If .Value IsNot Nothing Then
Filter = Filter & "[日期] >= #" & .Value & "#"
End If
End With
With RibbonTabs("凭证操作").Groups("收支").Items("结束日期")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 <= #" & .Value & "#"
End If
End With
Output.Show(Filter)
If Filter > "" Then
Tables("收入明细").Filter = Filter
End If
上述代码开始日期有日期,结束日期为空可以正常筛选,开始日期和结束日期不为空也可正常筛选,开始日期为空,结束日期不为空,不能正常筛选,提示开始日期为空默认为系统日期。请老六查看