查询条件一共4个,姓名,部门,日期和机构ID,错误现象,如果填上部门查询,日期筛选就失效了。谢谢各位老师了
Dim Filter As String
With e.Form.Controls("ComBoBox1")
If .Value IsNot Nothing Then
Filter = "(姓名 Like '%" & .Value & "%')"
End If
End With
With e.Form.Controls("ComboBox10")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = "(部门 Like '%" & .Value & "%')"
End If
End With
'==================================
With _groupadmin
If Filter > "" Then
Filter = Filter & " And "
End If
If _groupadmin = True Then '如果是管理员
Filter = Filter & "(市机构ID = '" & _usershijigouid & "')" '筛选所属市级的记录
Else
Filter = Filter & "(营业部ID = '" & _useryingyebuid & "')" '否则只筛选所属营业部的记录
End If
End With
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
'==========================
MessageBox.Show(filter, "提示")
If Filter > "" Then
DataTables("台账").loadFilter = Filter
DataTables("台账").load()
End If