toggle button

G

Guest

I created toggle buttons (from A to Z) at the bottom of a form (Form footer)
and would like them to return the results (in the same form).
Meaning that when I click on the button "A", the result would return all
records with Last Name starting with letter A.

HOW??
Thanks
 
R

Rick Brandt

margot_eon said:
I created toggle buttons (from A to Z) at the bottom of a form (Form
footer) and would like them to return the results (in the same form).
Meaning that when I click on the button "A", the result would return
all records with Last Name starting with letter A.

HOW??
Thanks

If you want previous toggle buttons to become un-depressed when you click on
a different one then put them all of them into an OptionGroup. Assign the
"A" toggle the numeric value of 97. The "B" button should be given the
value 98 and so forth for all buttons. Those numbers correspond to the
ASCII number of each lower case letter of the alphabet.

Then in the Change event of your OptionGroup...

Me.Filter = "[FieldName] like '" & Chr(OptionGroupName) & "*'"
Me.FilterOn = True
 
G

Guest

Write a function that sets the form's filter based on what was passed to it:

Private Function SetFirstLetter()
Dim strLetter As string

strLetter = Screen.Activecontrol.Caption
Me.Filter = "[LastName] LIKE '" & strLetter & "*'"
Me.FilterOn = True

End Function

The put this directly in the On Click text box of the Events tabk in the
controls property dialog

= SetFirstLetter()

That's all there is to it.
 
F

fredg

I created toggle buttons (from A to Z) at the bottom of a form (Form footer)
and would like them to return the results (in the same form).
Meaning that when I click on the button "A", the result would return all
records with Last Name starting with letter A.

HOW??
Thanks

Why re-invent the wheel?
Copy the "Customer Phone List" form (as well as the "Customer Phone
List" macro) from the sample Northwind.mdb that is already on your
computer.
 

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

Top