I'm trying to create a pop-up form to filter a report. The form has 5 drop down combo boxes and then the 3 command buttons. The five menus are searching for either numbers or letters. The first menu is looking for either 1 or 2, the second is looking for a three digit number, the third is a letter along with the fourth and the fifth is a couple letters.
I'm very confused with the syntax and I continue to get errors. I have been so turned around in the different forums that I'm really not sure what kind of code I need.
Right now I am able to pull up the pop-up menu in the report and it has data for the first 3 options, but for the second two it asks for me to enter a parameter value.
This is my code right now, and as I'm sure you guessed I am a beginner and very confused!
Private Sub Clear_Click()
Dim intCounter As Integer
For intCounter = 1 To 5
Me("Filter" & intCounter) = ""
Next
End Sub
Private Sub Close_Click()
DoCmd.Close acForm, Me.Form.Name
End Sub
Private Sub Form_Close()
DoCmd.Close acReport, "rptFeedwater" 'Close the Feedwater report.
DoCmd.Restore 'Restore the window size
End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenReport "rptFeedwater", A_PREVIEW 'Open Feedwater 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 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![rptFeedwater].fil
ter = strSQL
Reports![rptFeedwater].Fil
terOn = True
End If
End Sub
Start Free Trial