Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report Filter using a Form with combo boxes

Status
Not open for further replies.

Angelique21

Programmer
Jun 21, 2006
31
MT
Hi,
I am trying to filter a report by Form using combo boxes. On the form it contains 5 combo boxes that according to the user's preference it will filter the report.

Below is the code under ONCLICK BUTTON TO SET FILTER:

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![ShipTrack3].Filter = strSQL
Reports![ShipTrack3].FilterOn = True
Else
Reports![ShipTrack3].FilterOn = False
End If
End Sub

Private Sub Command29_Click()
Dim intCounter As Integer

For intCounter = 1 To 5
Me("Filter" & intCounter) = ""
Next
End Sub


the problem is that on the report you have more than five fields, but i set the form to be able to search only using 5 fields from the whole report. When i press filter report it gives me ENTER PARAMETER without any name and then it gives me a null report with no data on it. Something is wrong with this code, can anyone suggest any help.


thanks
 
put a debug.print StrSql in your code and post what the filter string looks like.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top