Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / May 2007

Tip: Looking for answers? Try searching our database.

sorting text field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bea. - 29 May 2007 13:03 GMT
What format can i use in order to sort one field containing first and last
name by last name only?  In table design view i have tried to put in a format
that would allow me to sort in the report design view, but i keep getting
error messages.
Any help would be appreciated.
Douglas J. Steele - 29 May 2007 13:23 GMT
There's no reliable way to sort under those conditions.

In what order would you want the following names sorted?

Mary Lou Retton
Ludwig von Beethoven
Walter de la Mare
Bono

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> What format can i use in order to sort one field containing first and last
> name by last name only?  In table design view i have tried to put in a
> format
> that would allow me to sort in the report design view, but i keep getting
> error messages.
> Any help would be appreciated.
Klatuu - 29 May 2007 13:48 GMT
A couple of points to consider.
As Douglas points out, the sorting would not be reliable.
I would recommend not sorting tables, but perform the sorting in you
queries, reports, or forms.
I would also recommend you not carry first and last name in the same field.  
A frequent question is "how do I parse out my first and last name from my
name field?"  The answer is, you can't do this with 100% accuracy.  There are
two many variable possibilites.  The same holds true for addresses.  It will
make your life much easier if you carry each part of a name separately.  To
put them together for display is very easy.  For a complete name you might
consider:
Prefix (Mr. Mrs., Dr. Sir, etc)
First Name
Middle Name
Last Name
Suffix (Esq, Jr, IV, etc)

Signature

Dave Hargis, Microsoft Access MVP

> What format can i use in order to sort one field containing first and last
> name by last name only?  In table design view i have tried to put in a format
> that would allow me to sort in the report design view, but i keep getting
> error messages.
> Any help would be appreciated.
Bea. - 29 May 2007 13:51 GMT
Many thanks for your reply, this is an assignment request, can you tell me if
there is an unreliable way? Hypothetically speaking if all the names were
simple like Jack Russell.

> What format can i use in order to sort one field containing first and last
> name by last name only?  In table design view i have tried to put in a format
> that would allow me to sort in the report design view, but i keep getting
> error messages.
> Any help would be appreciated.
Klatuu - 29 May 2007 14:11 GMT
First, drop the class.  The instructor is an idiot :)
I don't believe it can be done at the table level.
You can do it with a query.  To do that, you will need to create a
calculated field in the query and parse out the name.  The following example
assumes the rightmost part of the name field will always be the last name:

SortBy: Right([employeename],Len([employeename])-InStrRev([employeename]," "))

Signature

Dave Hargis, Microsoft Access MVP

> Many thanks for your reply, this is an assignment request, can you tell me if
> there is an unreliable way? Hypothetically speaking if all the names were
[quoted text clipped - 5 lines]
> > error messages.
> > Any help would be appreciated.
Bea. - 31 May 2007 12:45 GMT
Thankyou.

> First, drop the class.  The instructor is an idiot :)
> I don't believe it can be done at the table level.
[quoted text clipped - 13 lines]
> > > error messages.
> > > Any help would be appreciated.
gls858 - 29 May 2007 17:31 GMT
> Many thanks for your reply, this is an assignment request, can you tell me if
> there is an unreliable way? Hypothetically speaking if all the names were
[quoted text clipped - 5 lines]
>> error messages.
>> Any help would be appreciated.

Maybe it's a trick question and the correct answer is you can't:-)

gls858
John W. Vinson - 29 May 2007 16:38 GMT
>What format can i use in order to sort one field containing first and last
>name by last name only?  In table design view i have tried to put in a format
>that would allow me to sort in the report design view, but i keep getting
>error messages.
>Any help would be appreciated.

I fully agree with Douglas and Dave about the difficulties with this. I *hope*
the instructor is just giving an object lesson in why names should be broken
down into components as Dave suggests!

That said... you can base the Report on a Query containing two calculated
fields:

FirstName: Left([name], InStr([name], " "))
LastName: Trim(Mid([name], InStr([name], " ")))

Use these fields in the Report's Sorting and Grouping dialog; that's the only
way to sort data in a Report, it will ignore the sort order of a Query and
there *is* no such thing as the sort order for a table.

            John W. Vinson [MVP]
Bea. - 31 May 2007 12:44 GMT
Thanks for your suggestion.

> >What format can i use in order to sort one field containing first and last
> >name by last name only?  In table design view i have tried to put in a format
[quoted text clipped - 17 lines]
>
>              John W. Vinson [MVP]
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.