Angelique21
Programmer
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
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