如果是Access数据源,这样写,不要加多余空格或符号;如果是sqlserver数据库,#改成单引号'
Dim filter As String
With e.Form.Controls("datetimepicker1")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & " [开单日期] >= #" & .Value & "# "
End If
End With
With e.Form.Controls("datetimepicker2")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & " [开单日期] <= #" & .Value & "#"
End If
End With
If Filter > "" Then
DataTables("出库单据列表").LoadFilter = filter
DataTables("出库单据列表").Load()
End If