I want to filter the records in a form by filtering on multiple fields. The fields in the form are "ActionID", "OwnerID", "RequestorID" and "Due".
In the footer section of the form i have created following respective controls: "ActionIDFilter", "OwnerIDFilter", "RequestorIDFilter", "DueDateAfter" and "DueDateBefore".
The actual filtering gets executed after clicking the commandbutton "ApplyFiltersToToDoListForm".
Filtering runs perfect when i enter any valid value in fields "ActionIDFilter", "OwnerIDFilter" and "RequestorIDFilter".
Filtering runs not correct when i enter a valid date in fields "DueDateAfter" and "DueDateBefore".
Anyone any idea what is going wrong here ?
Thanks.
Jurgen
Expand|Select|Wrap|Line Numbers
- Private Sub ApplyFiltersToToDoListForm_Click()
- Dim strFilter As String
- If ActionIDFilter <> "" Then
- strFilter = "ActionID = " & ActionIDFilter
- Else
- If OwnerFilter <> "" Then
- strFilter = "OwnerID = " & OwnerFilter
- End If
- If RequestorFilter <> "" Then
- If strFilter <> "" Then
- strFilter = strFilter & " AND "
- End If
- strFilter = strFilter & "RequestorID = " & RequestorFilter
- End If
- If DueDateAfter <> "" Then
- If strFilter <> "" Then
- strFilter = strFilter & " AND "
- End If
- strFilter = strFilter & "Due >= " & DueDateAfter
- End If
- If DueDateBefore <> "" Then
- If strFilter <> "" Then
- strFilter = strFilter & " AND "
- End If
- strFilter = strFilter & "Due <= " & DueDateBefore
- End If
- End If
- Me.Filter = strFilter
- Me.FilterOn = True
- End Sub