more than one filter? Help!

P

paula k

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...
 
J

Jeff L

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!
 
P

paula k

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
 
D

Douglas J. Steele

You left out the keyword And:

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top