Address Book buttons

  • Thread starter Thread starter RC
  • Start date Start date
R

RC

I have seen some databases, like an address database, where within a form,
there are a column of buttons from A to Z which, when pressed, filter the
records in that database. Does each button have to be setup individually or
is there an easier method to get this functionality?
 
I have seen some databases, like an address database, where within a form,
there are a column of buttons from A to Z which, when pressed, filter the
records in that database. Does each button have to be setup individually or
is there an easier method to get this functionality?

No, those buttons are actually in one option group.
Instead of the usual Option Group Radio Buttons, Toggle Buttons are
used. Each toggle has a value of 1 through 26.
When, for example, the "F" button is clicked, the Option Group takes
the value of the "F" button which is 6), and filters the data
accordingly.
You have just one Option Group, but you would have to add the 26
ToggleButtons to it.

You could also use a single command button, which would offer the
wanted letter by moving the cursor over the button until the correct
letter appeared. Personally, I like the option group as it's a bit
faster and the user is less likely to select the wrong letter.
 
That is a really good idea, fredg. I would add one little trick to make the
codeing for the filtering easier. Rather than 1 to 26 which would take a
loop or a long Select Case, you could make the option vaules 65 through 90.
These are the ASC values of "A" through "Z"

So then to filter, all you need is to use the Chr() function

Me.Filter = "[SomeField] LIKE """ & Chr(Me.MyOptionGroup) & "*"""
Me.FilterOn = True
 
That is a really good idea, fredg. I would add one little trick to make the
codeing for the filtering easier. Rather than 1 to 26 which would take a
loop or a long Select Case, you could make the option vaules 65 through 90.
These are the ASC values of "A" through "Z"

So then to filter, all you need is to use the Chr() function

Me.Filter = "[SomeField] LIKE """ & Chr(Me.MyOptionGroup) & "*"""
Me.FilterOn = True

Sounds good to me.
Microsoft actually used macros.

I'm glad you brought this up as I forgot to tell the OP where he/she
could see/get the form.

RC. You can see it in the Northwind Sample database that ships with
Access. Unfortunately, it is not shown on the Db Switchboard, so you
have to get it from the Main database window:
"Customer Phone List".
Then also look at/import the Macro "Customer Phone List".
 
Microsoft actually used macros.

Just because Microsoft wrote Access doesn't mean they really know how to use
it :)

--
Dave Hargis, Microsoft Access MVP


fredg said:
That is a really good idea, fredg. I would add one little trick to make the
codeing for the filtering easier. Rather than 1 to 26 which would take a
loop or a long Select Case, you could make the option vaules 65 through 90.
These are the ASC values of "A" through "Z"

So then to filter, all you need is to use the Chr() function

Me.Filter = "[SomeField] LIKE """ & Chr(Me.MyOptionGroup) & "*"""
Me.FilterOn = True

Sounds good to me.
Microsoft actually used macros.

I'm glad you brought this up as I forgot to tell the OP where he/she
could see/get the form.

RC. You can see it in the Northwind Sample database that ships with
Access. Unfortunately, it is not shown on the Db Switchboard, so you
have to get it from the Main database window:
"Customer Phone List".
Then also look at/import the Macro "Customer Phone List".
 
Back
Top