MS Access FilterOn Error (Solution)

This may help give you a clue to why your Me.FilterOn is not working properly.

My form was doing some filters, but when it came to filtering the date, it wasn’t operating correctly.

Here is my filtering code:

If Len(FilterString) > 0 Then
    Me.Filter = FilterString
    Me.filterOn = True
End If

I noticed that if I set one filter that didn’t have the date, the “Me.FilterOn” action was equalling to “True”.

However, when I was filtering on the date “Me.FilterOn” was equalling to “False”.

Huh? Could it be that Access was actually smart 🙂 ? Could it actually figure out that I had some syntax error?

Well…maybe…it did this time! I was missing a closing parentheses!

FilterString = FilterString & "Year([START DATE])=" & val(Me.sysComboYear) & " And Month([START DATE])=" & val(Me.sysComboMonth)

I added the closing parentheses, and , “Me.FilterOn = True”

So maybe this solution will help someone else.


Comments are closed.