Link to home
Start Free TrialLog in
Avatar of dewster1971
dewster1971

asked on

Filter a continuous form

I have a form that I would like to filter based on the month and year.  I have copied over a form that had the follow code behind a command button.  In this form, there is not original strCoreFilter.  I simply want the filter to be

Me.Filter = strCoreFilter & IIf(Trim(strCoreFilter) <> "", " AND ", "") & " [Visit Month]=2" & " AND " & "Year([VisitDate]) = " & Me.cboYear


I simply want the filter to be:
 [Visit Month]=2" & " AND " & "Year([VisitDate]) = " & Me.cboYear

but when I try Me.Filter =  [Visit Month]=2" & " AND " & "Year([VisitDate]) = " & Me.cboYear, I don't get any filtering to work properly.  

I will also have several other command buttons for other months and I would need to be able to restore all data before running the next filter.  Clear, I hope so.

Any suggestions?
Avatar of MikeToole
MikeToole
Flag of United Kingdom of Great Britain and Northern Ireland image

You will also need me.FilterOn = True
Avatar of dewster1971
dewster1971

ASKER

So what's the entire code look like?

me.FilterOn = True
Me.Filter =  [Visit Month]=2" & " AND " & "Year([VisitDate]) = " & Me.cboYear
You will need to Apply the filter ...

DoCmd.ApplyFilter

ET
ASKER CERTIFIED SOLUTION
Avatar of Eric Sherman
Eric Sherman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you want to use this method then you will need the code in this order ...

Me.Filter =  [Visit Month]=2" & " AND " & "Year([VisitDate]) = " & Me.cboYear
me.FilterOn = True

ET