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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting text field based on 2nd word in field

Status
Not open for further replies.

ThornPCC

Programmer
Jan 6, 2000
26
US
Hi,<br>
<br>
I have a database that has a persons name in one field. It's in first name last name order. I need to print the list in last name order. I don't want to break up the field if I can avoid it. Most of my reports are sorted on a different field, but 3 reports will use the last name.<br>
Did I mention that I import the data from a DBF file every morning? So short of designing a query to break up the field after import, I'm slightly baffled.<br>
<br>
Thanks. <p>Phil<br><a href=mailto:Thorn@full-moon.com>Thorn@full-moon.com</a><br><a href= > </a><br>Most of us go through life not knowing what we want, but feeling damned sure that this isn't it.<br>

 
NO there is no easy way or function.<br>
If of example you need to print them in Last name, First name it can still be done.<br>
It is easier to assemble data i.e. Add the last name to the first name and a comma than to dis-assemble it.<br>
<br>
Because of the following reasons.<br>
Some people have periods in their names Jr. Sr. Dr.<br>
Some names are <br>
J.T. Smith <br>
James T. Smith<br>
and you can come up with more.<br>
So it is difficult to write a bunch of IF statements for every conceivable name.<br>

 
I have thought of a way to do this. I must have been suffering from a temporary blockage. I have a table that contains the employee's names and addresses as well as employee number. The table I'm printing from has the employee number as well. I can build a query to lookup the names based on employee number.<br>
<br>
DOH !!!!!<br>
<br>
Thanks for the quick reply. <p>Phil<br><a href=mailto:Thorn@full-moon.com>Thorn@full-moon.com</a><br><a href= > </a><br>Most of us go through life not knowing what we want, but feeling damned sure that this isn't it.<br>

 
I used to keep a table of all actors in every film known to my database. With 16,000 films I had a LOT of actors. They were all listed in firstname lastname order and someone wanted an index by surname order.<br>
<br>
Use find to check if there is a space in the string. If there are 0 or 2 spaces return empty string or &quot;ZZZ name&quot; or whatever, otherwise put right(name(find(&quot; &quot;,name)+1,len(name)&&quot;, &quot;&left(name,find(&quot; &quot;,name)-1) or thereabouts.<br>
<br>
It's not the fastest query in the world though, but I ran it successfuly on a 486SX25...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top