"Order By" event on form with 3 alpha bars

P

PZ Straube

My question is how do I let a user work with three different alpha bars on
a single form and when they click on a letter of any of the alpha bars, it
will
sort the records based on the purpose of the particular alpha bar they used.
For example, if they use the Maiden Name alpha bar, the records will be sorted
by Maiden Name and show only records starting with the letter they chose.
Likewise, if they click on a letter of the First Name alpha bar, the records
are sortedby First Name and show only records starting with that letter.
Thanks for your help.
 
D

Dirk Goldgar

PZ Straube said:
My question is how do I let a user work with three different alpha
bars on
a single form and when they click on a letter of any of the alpha
bars, it will
sort the records based on the purpose of the particular alpha bar
they used. For example, if they use the Maiden Name alpha bar, the
records will be sorted by Maiden Name and show only records starting
with the letter they chose. Likewise, if they click on a letter of
the First Name alpha bar, the records are sortedby First Name and
show only records starting with that letter. Thanks for your help.

I don't know from your description exactly what these "alpha bars" are
or how they are implemented. I'm picturing each as a row of 26 command
buttons, captioned "A" to "Z", and I'm going to suggest a solution based
on that idea.

Set the Tag property of each command button in a given alpha bar to the
name of the field that is to be sorted and filtered. So all the
buttons, A-Z, for MaidenName will have the Tag property set to
"MaidenName", and all the ones for FirstName" will have the Tag property
set to FirstName, and so on. If these field names have embedded
spaces -- a bad idea -- surround the field names with square brackets
([]) in the Tag property (e.g., "[Maiden Name]"). Let each button have
a caption which is a single letter, "A" to "Z".

Set every one of these buttons' On Click event property to the following
function expression:

=FilterAndSort()

Create the following function in the General section of the form's code
module:

'----- start of code -----
Function FilterAndSort()

With Me.ActiveControl
Me.OrderBy = .Tag
Me.Filter = .Tag & " Like '" & .Caption & "*'"
Me.FilterOn = True
Me.OrderByOn = True
End With

End Function
'----- end of code -----

That's untested, but I believe it should work.
 

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