Solved

# Filter a continuous form

Posted on 2006-05-26
Medium Priority
225 Views
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?
0
Question by:dewster1971
• 3

LVL 27

Expert Comment

ID: 16771245
You will also need me.FilterOn = True
0

Author Comment

ID: 16771314
So what's the entire code look like?

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

LVL 19

Expert Comment

ID: 16771438
You will need to Apply the filter ...

DoCmd.ApplyFilter

ET
0

LVL 19

Accepted Solution

Eric Sherman earned 1000 total points
ID: 16771765
Actually, this should work for you ...

DoCmd.ApplyFilter, "[Visit Month]=2" & " AND " & "Year([VisitDate]) = " & Me.cboYear

ET
0

LVL 19

Expert Comment

ID: 16772057
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
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
###### Suggested Courses
Course of the Month15 days, 10 hours left to enroll