Quote:
Originally Posted by JKing
I'm almost 100% sure the problem lies within strSQL. I think Me("Filter" & intCounter).Tag is returning Null so you're left with [] within your strSQL which is what is prompting you to enter a parameter. To verify this do a Debug.Print strSQL after your for loop. This will show you what criteria you're passing to the filter.
If this is indeed the problem. I can help you properly build the filter string if you tell me what controls and fields you are using on your form.
I just tried to learn this over the past two days so I'm not quite sure what you need. I already appreciate all that you're doing so if you can really decifer what the heck this all is then you will be my new super hero.
My Popup 'Presentation Filter' Form looks like this:
Presenter: (Filter1)
rowsource:SELECT Data.[Presenter's Name] FROM Data GROUP BY [Presenter's Name]; Evaluator: (Filter2)
rowsource: SELECT Data.Evaluator FROM Data GROUP BY [Evaluator]; Date: (Filter3)
rowsource: SELECT Data.Date FROM Data GROUP BY [Date]; Topic: (FIlter4)
rowsource: SELECT Data.Topic FROM Data GROUP BY [Topic]; (commandbutton)'Clear'
(commandbutton)'Set Filter'
I'm trying to use these to filter my 'rptEvaluation' report. All fields come from my 'Data' table.
This is everything I have:
Private Sub Clear_Click()
Dim intCounter As Integer
For intCounter = 1 To 4
Me("Filter" & intCounter) = ""
Next
End Sub
Private Sub Form_Close()
DoCmd.close acReport, "rptEvaluation" 'Close the Evaluation report.
DoCmd.Restore 'Restore the window size
End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenReport "rptEvaluation", A_PREVIEW 'Open Evaluation report.
DoCmd.Maximize 'Maximize the report window.
End Sub
Private Sub Set_Filter_Click()
Dim strSQL As String, intCounter As Integer
'Build SQL String
For intCounter = 1 To 4
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![rptEvaluation].filter = strSQL
Reports![rptEvaluation].FilterOn = True
Else
Reports![rptEvaluation].FilterOn = False
End If
End Sub