467,921 Members | 1,303 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,921 developers. It's quick & easy.

Alphabetical Filter Bar

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
  • viewed: 3666
Share:
2 Replies
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
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.

Similar topics

1 post views Thread by Richy Rich | last post: by
2 posts views Thread by David Veeneman | last post: by
3 posts views Thread by simonZ | last post: by
7 posts views Thread by Ron Adam | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.