Hoping you are able to help me with a filtering scenario:
I have created a pop up form (Filter) to filter a report (Open Issues), which currently has a number of combo boxes which apply the filters to the fields in the report.
I would like to use this form to filter the report within a date range (Raised Date From and Raised Date To), using unbound text boxes, without having to specify the criteria within the report's underlying query (query is used to create more that one report).
The following is the code I have written for the 5 current combo boxes (Filter1 - Filter 5) I have on the pop up form:
Expand|Select|Wrap|Line Numbers
- Private Sub Set_Filter_Click()
- Dim strSQL As String, intCounter As Integer
- 'Build SQL String
- For intCounter = 1 To 5
- If Me("Filter" & intCounter) <> "" Then
- strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "]" & "=" & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
- End If
- Next
- If strSQL <> "" Then
- 'Strip Last " And ".
- strSQL = Left(strSQL, (Len(strSQL) - 5))
- 'Set the Filter property
- Reports![Open Issues].Filter = strSQL
- Reports![Open Issues].FilterOn = True
- End If
- End Sub
Any assistance would be greatly appreciated!