By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,393 Members | 1,523 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,393 IT Pros & Developers. It's quick & easy.

Alphabetical Filter Bar

P: n/a
I have been creating a contact management database which now has about
300 records in it. I've been filtering using the "filter by form"
command but I'd like to automate this with a set of buttons at the top
of the form. The buttons would look something like this:

ABC DEF GHI JKL MNO PQRS TUV WXYZ

Each button would filter the records by Last Name.

Being a newbie to Access, I don't know exactly how to do this. I'm
assuming I use a command button. But what I don't know is whether to
use a filter, a simple query or a parameter query and just how to link
the button to the solution I choose.

If some one could offer me general direction here I'd be grateful. If
you supply me with the basic method, I can lookup the details in
Access Help or on the Microsoft support site.

Thanks!

Matt Edminster

Aug 11 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Chiinook - yes command buttons would work for this
In the command button's "on click" event, you would (in the code
builder) put the following visual basic code:

Me.Filter = "left([LastName],1) in ('a','b','c')"
Me.FilterOn = True
(assuming your field name - not the textbox name- is "LastName")

You will have to have some other method for turning off the filter,
maybe a "reset" button, for which you would say:
me.filter0n= false

OR --
You could make a fancier search instead of all those buttons, by using
an unbound textbox (maybe placed in the form's header). The user could
type in the beginning of a name (or just one letter), and then click a
button and the form would filter to anything that resembles what they
typed. For this you would say: (again in the 'on click' event)

me.filter ="LastName like '" & me.txtSearchBox & "*'"
me.filterOn = true

These solutions assume that you have all the records loaded into the
form to begin with. When you start getting really large sets of data, or
have several users, its often good to not load all the data at once, but
just load the data that you are "searching" for. In this case, you set
the form's recordset on the fly -- This is probably fancier than you
need or want right now, but just letting you know about the method.

hope this helps
-John
chiinook wrote:
I have been creating a contact management database which now has about
300 records in it. I've been filtering using the "filter by form"
command but I'd like to automate this with a set of buttons at the top
of the form. The buttons would look something like this:

ABC DEF GHI JKL MNO PQRS TUV WXYZ

Each button would filter the records by Last Name.

Being a newbie to Access, I don't know exactly how to do this. I'm
assuming I use a command button. But what I don't know is whether to
use a filter, a simple query or a parameter query and just how to link
the button to the solution I choose.

If some one could offer me general direction here I'd be grateful. If
you supply me with the basic method, I can lookup the details in
Access Help or on the Microsoft support site.

Thanks!

Matt Edminster
Aug 11 '07 #2

P: n/a
John

That helps immensely! Thank you.

Matt

On Aug 11, 4:00 pm, John Welch <so...@nospam.comwrote:
Chiinook - yes command buttons would work for this
In the command button's "on click" event, you would (in the code
builder) put the following visual basic code:

Me.Filter = "left([LastName],1) in ('a','b','c')"
Me.FilterOn = True
(assuming your field name - not the textbox name- is "LastName")

You will have to have some other method for turning off the filter,
maybe a "reset" button, for which you would say:
me.filter0n= false

OR --
You could make a fancier search instead of all those buttons, by using
an unbound textbox (maybe placed in the form's header). The user could
type in the beginning of a name (or just one letter), and then click a
button and the form would filter to anything that resembles what they
typed. For this you would say: (again in the 'on click' event)

me.filter ="LastName like '" & me.txtSearchBox & "*'"
me.filterOn = true

These solutions assume that you have all the records loaded into the
form to begin with. When you start getting really large sets of data, or
have several users, its often good to not load all the data at once, but
just load the data that you are "searching" for. In this case, you set
the form's recordset on the fly -- This is probably fancier than you
need or want right now, but just letting you know about the method.

hope this helps
-John

chiinook wrote:
I have been creating a contact management database which now has about
300 records in it. I've been filtering using the "filter by form"
command but I'd like to automate this with a set of buttons at the top
of the form. The buttons would look something like this:
ABC DEF GHI JKL MNO PQRS TUV WXYZ
Each button would filter the records by Last Name.
Being a newbie to Access, I don't know exactly how to do this. I'm
assuming I use a command button. But what I don't know is whether to
use a filter, a simple query or a parameter query and just how to link
the button to the solution I choose.
If some one could offer me general direction here I'd be grateful. If
you supply me with the basic method, I can lookup the details in
Access Help or on the Microsoft support site.
Thanks!
Matt Edminster

Aug 11 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.