Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alpha Sort List on Form...

Status
Not open for further replies.

SherryLynn

Technical User
Feb 4, 2001
171
CA
I have a form which has a button for selecting individuals from a list. When I click the button it brings up a form with the alphabet buttons (the list of individuals is very long, so it's easier to go by letter groups). When a letter button is pressed the appropriate list is viewed (lets say "S"). The list appears in alphabetical order by last name. I would like this list to then sort each group of the same names (say "Smith") alphabetically by their first name. Right now they appear like this:

Smith, John
Smith, Abe
Smith, Gloria
Smith, Ben

I would like them to appear as:

Smith, Abe
Smith, Ben
Smith, Gloria
Smith, John

I'm sure this is a simple thing to fix, but I didn't create this form and am not sure what to do. Can anyone help?

Thanks a million,
Sherry
 
Sherry, is this information in a query some place where the first name and last name are in two separate Fields. If yes, then you can do the sort there. You would have to sort by last name first and then first name. Get rid of any other sort in that query (i.e. Primary key). If the fields don't exist in separate fields some place then you will need to sort them in the list that you currently have. To do this, you would add something like the following to two columns in the underlying query.

MySort1:Mid([NameField],1,Instr(1,[NameField],",")-1)
Sort this field ascending

MySort2:Mid([NameField],Instr(1,[NameField],",")+1)
Sort this field ascending
This should return Fields that read
Smith John
By sorting these fields, you should be able to get your names in the correct order.
Take out any other sorts you have in the query.

Post back if you have any problems.

Paul
 
In the second case (no seperate field for last name), I have previously posted a routine "[b'basSplit[/b]" which would do the name seperation nicely for this syntax. There should be several posts which include the procedure and some specific examples of useage.

MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Thank you both for your help. I'm working on this now and will let you know how it works.

Sherry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top