View Full Version : Filter reporting


BrainStorm
08-19-2005, 11:14 AM
I have a form that displays filter options, acting as a pop-up screen over a report preview that i wish to filter. I have 5 filter options. Choosing these options in any combination and hiting the "set filter" button should result in the report being filtered and results displayed on the report preview.

The "Set Filter" button has the following code attached to it:


Private Sub Command28_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![rptp1Learning].Filter = strSQL
Reports![rptp1Learning].FilterOn = True
End If
End Sub
(The control boxes used as filter options are named filter1,filter2,filter3...)

When i open the form and choose filter option(s), i get a prompt saying "enter parameter Value". This happens only the first time of opening the form. Non of the filter options work and no filtering is performed. No coding errors appear. Iam stumped and dont know why this simple filtering technique is not working for me.
Any ideas ?