Filter Report by Form Not Working

kentwood

Registered User.
Local time
Today, 15:05
Joined
Aug 18, 2003
Messages
51
I have a report "Work Order Details" that that is based on a query and opens along with a form that is used to set filters. Based on samples I have looked at and reading, I cannot figure out what is missing. When I select my item form one of 5 unbound combo box 's and click the "Set filter" button, it brings up a paramter box?? If I cancel out the box, I still don't get a result. Just for the heck of it, I filled in a name in the paramter box, still no luck. The report property has "Filter On" as YES. The close button, clear button, and drops downs operate perfectly.

Here is the On Click Event info from my "set filter" button:

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![Work Order Details].Filter = strSQL
Reports![Work Order Details].FilterOn = True
End If

End Sub
 
I would be inclined to put a breakpoint at the start of this code, and step through a line at a time. I think you are building an invalid SQL string.

for instance the line
If Me("Filter" & intCounter) <> "" Then

appears strange as you ought to have a . or ! operator after the me. Does it work?
 
Filter Report by Form

No, that did not work, but I did find out what was wrong. The tag names were not set on my property fields correctly. I have everything working perfectly. When the report is opened, it will autmatically open the filter form that contains the combo box's that are used for filtering.

Although it is really good right now, I was wondering about one other thing. Right now, when I clear the filter, the report continues to show the record(s) that are a result of the filer. It is also set so that when the filter box is closed, the report closes as well.

What if my user filtered some records, clears the filer and wants to print all the records (unfiltered)? For the event procedure on the Clear filter, how would I allow the report to be set back to the complete version?

To help you understand, I have attached the abreviated database.
 

Attachments

Users who are viewing this thread

Back
Top Bottom