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 / Modules / DAO / VBA / February 2005

Tip: Looking for answers? Try searching our database.

Can Access correctly sort Library of Congress Call Numbers?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
William Gee - 26 Feb 2005 22:57 GMT
I'm working in a library and we're creating a database of collection items,
but I can't seem to get Access to sort them by Library of Congress call
number correctly. Access sorts, for instance, S1.U556, S115.E32, S16.I6732 in
that order, rather than S1.U556, S16.I6732, S115.E32. Any ideas on how to
change the sort setting? Any idea how to create a new type of Access field
for this data that would sort correctly?
Marshall Barton - 26 Feb 2005 23:32 GMT
>I'm working in a library and we're creating a database of collection items,
>but I can't seem to get Access to sort them by Library of Congress call
>number correctly. Access sorts, for instance, S1.U556, S115.E32, S16.I6732 in
>that order, rather than S1.U556, S16.I6732, S115.E32. Any ideas on how to
>change the sort setting? Any idea how to create a new type of Access field
>for this data that would sort correctly?

Tables are not sorted, so use a query that selects the
appropriate fields from the table.  Add a calculated field
like:
    Expr: Val(Mid(LCnumfield, 2))
and set it to sort ascending.

You may need to refine this, but I don't know what it might
be.

Signature

Marsh
MVP [MS Access]

John Vinson - 27 Feb 2005 00:53 GMT
>I'm working in a library and we're creating a database of collection items,
>but I can't seem to get Access to sort them by Library of Congress call
>number correctly. Access sorts, for instance, S1.U556, S115.E32, S16.I6732 in
>that order, rather than S1.U556, S16.I6732, S115.E32. Any ideas on how to
>change the sort setting? Any idea how to create a new type of Access field
>for this data that would sort correctly?

As Marshall says, tables HAVE NO ORDER - they're unordered "heaps" of
data. You need to use a Query to sort records.

Access is sorting these values as single text strings; S1.U556 sorts
before S115.E32 because the character . is before the character 1 in
the collating sequence for strings. Access has NO way to know that you
*intend* the 1 and the 115 to be numeric values. I'm not sure what the
range of variation of these codes might be. If a valid call number
ALWAYS consists of two portions, each consisting of a single
alphabetic character followed by a number, you might want to consider
storing the call number in *four* fields rather than one: TextMajor
(Text 1), NumMajor (Integer), TextMinor (Text 1), and NumMinor
(Integer). S1.U556 would be stored as S, 1, U, and 556 respectively;
you can write an expression to concatenate the four fields for display
purposes. And they'll sort correctly.

To sort these values with the existing structure you'll need to use
some complex Mid() and InStr() expressions to parse out the letters
and numbers, and the sort will likely be VERY inefficient.

                 John W. Vinson[MVP]    
David C. Holley - 27 Feb 2005 14:30 GMT
If I remember my basic office skills correctly, Access is sorting the
values correctly by standard methods S115 would come before S16 since
the 3rd character '1' comes before '6'. Access is viewing the values as
TEXT as opposed to NUMBERS. The values that you need can be converted
from text to numeric by writting some code to extract the values and
convert them. The code should be relatively simply, but a bit longer
than I can come up with spur of the moment.

David H
Come on baby light my fire: www.spreadFireFox.com

> I'm working in a library and we're creating a database of collection items,
> but I can't seem to get Access to sort them by Library of Congress call
> number correctly. Access sorts, for instance, S1.U556, S115.E32, S16.I6732 in
> that order, rather than S1.U556, S16.I6732, S115.E32. Any ideas on how to
> change the sort setting? Any idea how to create a new type of Access field
> for this data that would sort correctly?
Tim Ferguson - 27 Feb 2005 16:37 GMT
>  Any idea how to create a new type of Access field
> for this data that would sort correctly?

 SELECT Whatever
 FROM Wherever
 ORDER BY CInt(Val(Mid$(CallNumber,2))) ASC

Hope that helps

Tim F
Dirk Goldgar - 27 Feb 2005 17:32 GMT
> I'm working in a library and we're creating a database of collection
> items, but I can't seem to get Access to sort them by Library of
[quoted text clipped - 3 lines]
> to create a new type of Access field for this data that would sort
> correctly?

This question has been answered in another group to which you posted it
separately.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
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.