473,406 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Is it possible to filter ontop of the current filter?

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

Nov 13 '05 #1
4 1615
Crispy,

Yes, its doable. You just need to combine the two filter clauses with
an "And". Do this in a separate subroutine in your form module:

Private Sub FilterMe()

Dim sFilter as String

sFilter = ""

If Me.Dirty Then 'Save first
Me.Dirty = False
End If

If Not IsNull(Me.Text67) Then
sFilter = "[SLastName] Like """ & Me.Text67 & "*"""
End If

If Not IsNull(Me.cmbFSchoolYear) Then
If Len(sFilter) > 0 Then
sFilter = sFilter & " And "
End If
sFilter = sFilter & "[SchoolYear] Like """ & Me.cmbFSchoolYear &
"*"""
End IF

If Len(sFilter) > 0 Then
Me.Filter = sFilter
Me.FilterOn = True
Else
Me.FilterOn = False
End IF

End Sub

This builds your filter string, adding an "And" if both filter
conditions are used. If neither filter control is set, it turns the
filter off.

-Ken

Nov 13 '05 #2
Ken,

Thank you for your help. I really appreciate it. That worked perfectly.
Thanks again!

Nov 13 '05 #3
Ken,

One last question. This works if they first filter on Last Name and
then choose from the school year menu...

Is it possible to also make it work if they decide to first filter on
School year and then last name?

So that both scenerios work?

Nov 13 '05 #4
Nevermind. I take that back.

Thanks!

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Dario de Judicibus | last post by:
I wish to implement a simple C++ filter that reads from a file byte by byte and writes to an output files two bytes for each byte read according to some hardcoded table. I am looking for a very...
2
by: Salad | last post by:
I have a log file with a list of records. The log file can be unfiltered or filtered. I have a command button to call a data entry form from the log. At first I was only going to present the...
3
by: Afton | last post by:
I would like to make a form that filters a report by Supervisor and by starting and ending date. I have the supervisors in a combo box, and that works. However, I do not know how to code to let...
2
by: cefrancke | last post by:
I have a form (no underlying record set) that has two separate sub-forms on it. Each sub-form has data from two different tables. Above each sub-form there is one unbound combo box with a SQL...
1
by: ViRi | last post by:
I am writing my own little video player, using AxMicrosoft.MediaPlayer.Interop.AxWindowsMediaPlayer, and i want to add stats when in fullscreen. I am able to Draw to it with GDI+, but since...
0
by: mpdoreilly | last post by:
Hi, I've a webservice that has several typical webmethods that clients call and get responses from. (Side note: The websriivce is actually to implement the server side of tr-069, the protocol...
5
by: perryche | last post by:
Is there a way to have a message popup ontop of all windows (not only in Access, but ontop of other windows) to give users a warning message? Does windows XP itself have anykind of instant...
3
by: franc sutherland | last post by:
Hello, I have a report which I filter using the me.filter command in the OnOpen event. Me.Filter = "OrderID=" & Forms!variable_form_name! Me.FilterOn = True I want to be able to open that...
0
by: newcooler | last post by:
I have a junction table for instance 1 service can have many contacts - using a composite key junction table. what i want to do is to filter all the contacts that belong to the service using the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.