more than one filter? Help!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there...I finally have gotten all of my filters to work (thanks to this
forum!)...I now have an additional question about using more than one filter
on a form.

I have the following type of data:

Project_Name Project_Owner Project_Year ...
1 Paula 06
2 Paula 06
3 Vickie 06
4 Paula 07
5 Bob 07

I am using the following code to filter these individually:

Private Sub cbo_find_Owner_AfterUpdate()
Dim strFilter As String

strFilter = "Owner_ID = " & Nz(Me.cbo_find_Owner, 0)
Me.Filter = strFilter
Me.FilterOn = True

End Sub



I still would like to filter individually, but also combine filtering...such
as filtering by Project_Owner AND by Project_Year. How do I do this??

Thanks for your help in advance...
 
You would simply add too your strfilter by using And. So if you wanted
to find all projects that someone owns where the Project Year is a
given year, then your filter would be
strFilter = "Project_Owner = '" & Me.txtProjOwner & "' And Project_Year
= '" & Me.txtProjYear & "'"

Hope that helps!
 
I'm probably just doing something wrong...but I'm getting an error...maybe
its because I'm filtering via combo boxes??

Private Sub cbo_find_Owner_AfterUpdate()
Dim strFilter As String

strFilter = "Owner_ID = " & Nz(Me.cbo_find_Owner, 0) & "Project_Year = " &
(Me.cbo_find_Project_year, 0)
Me.Filter = strFilter
Me.FilterOn = True

End Sub
 
You left out the keyword And:

strFilter = "Owner_ID = " & Nz(Me.cbo_find_Owner, 0) & _
"And Project_Year = " & (Me.cbo_find_Project_year, 0)
 
Back
Top