Is it possible to filter ontop of the current filter?

C

crispywafers

Hi,

Is it possible to filter ontop of the current filter being applied to
records? This seems like it should be easy?

I have two drop down boxes-- one to filter on a student's last name,
one to filter on the current school year. They work seperatly, but not
together. I would like a user, if they want, to be able to apply both
filters at once -- (only a certain school year and only a certain
student). Help?

Current code:

First Drop Down box (filter on Last Name):

Private Sub Text67_Change()
If Me.Dirty Then 'Save first
Me.Dirty = False
End If
If IsNull(Me.Text67) Then 'Show all
Me.FilterOn = False
Else

Me.Filter = "[SLastName] Like """ & Me.Text67 & "*"""

Me.FilterOn = True
End If
End Sub

Second Drop Down Box (filter on school year):

Private Sub cmbFSchoolYear_Change()

If Me.Dirty Then 'Save first
Me.Dirty = False
End If
If IsNull(Me.cmbFSchoolYear) Then 'Show all
Me.FilterOn = False
Else

Me.Filter = "[SchoolYear] Like """ & Me.cmbFSchoolYear & "*"""
Me.FilterOn = True
End If

End Sub
 
T

tina

the second filter needs to be a combination of both the single filters you
currently use. assuming that the individual filters you posted already work,
try combining them as

Me.Filter = "[SchoolYear] Like """ & Me.cmbFSchoolYear & "*"" And
[SLastName] Like """ & Me.Text67 & "*"""

it's confusing with all the quote marks, you'll probably have to play with
it.

btw, does your school year field contain only the year value: 2002, 2003,
2004, etc? does your SLastName field contain only the student's last name:
Smith, Jones, Brown? and does your user type the entire last name in control
Me.Text67? if yes to all three questions, why do you need the asterisk wild
card character at the end of each value in the filter expression? the
following might work just as well, as

Me.Filter = "[SchoolYear] = " & Me.cmbFSchoolYear & " And [SLastName] = '" &
Me.Text67 & "'"

the above assumes that SchoolYear is a numeric field. if it's a text field,
try

Me.Filter = "[SchoolYear] = '" & Me.cmbFSchoolYear & "' And [SLastName] = '"
& Me.Text67 & "'"

hth
 

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

Combo Box Filter not working 3
Filter by form woes (posted inadvertantly first in the queries sub 1
Form Filter 5
check box in filter 3
Filter code 1
Run-time erroe '2001' 6
Filter problem 2
Event Question 1

Top