Filter issue.

cursedeye

Registered User.
Local time
Today, 16:07
Joined
Oct 7, 2009
Messages
50
I have a function that calls out filter.

It does his job well, but when it can't find any match just returns a blank page with nothing on it, so the only way is to close it and open it again.

I'd like to have a warning or reset to it's initial state when it can't find any result.

How do I do it?

Thanks
 
Posting the code in your function would be a good start :)
 
My code:

Private Sub Class_AfterUpdate()
Call CheckFilter
End Sub



Private Sub CheckFilter()
Dim strFilter As String, strOldFilter As String

strOldFilter = Me.Filter
'Class - Numeric
If Me!Class > "" Then _
strFilter = strFilter & _
" AND ([Class ID]=" & _
Me!Class & ")"

'Debug.Print ".Filter = '" & strOldFilter & "' - ";
'Debug.Print "strFilter = '" & strFilter & " '"
'Tidy up results and apply IF NECESSARY
If strFilter > "" Then strFilter = Mid(strFilter, 6)
If strFilter <> strOldFilter Then
Me.Filter = strFilter
Me.FilterOn = (strFilter > "")
End If
End Sub


Thanks
 
Well, if I'm reading this right:

Code:
If strFilter > "" Then strFilter = Mid(strFilter, 6)

If strFilter <> strOldFilter Then
    Me.Filter = strFilter
    Me.FilterOn = (strFilter > "")
End If

If the string comes back as nothing and the previous filter has something, then the filter is going to be a zero length string. I dunno if
Me.FilterOn = (strFilter > "")
will actually set the filter, but what happens if strFilter is = ""?

Would be good to put in some Else statements.

Code:
If strFilter > "" Then 
    strFilter = Mid(strFilter, 6)
else
    me.filteron = false
end if
 
If strFilter <> strOldFilter Then
     Me.Filter = strFilter
     Me.FilterOn = True
End If
Note this is aircode....I dont use filters much...so you might want to play around with it.
 

Users who are viewing this thread

Back
Top Bottom