Results 1 to 5 of 5
  1. #1
    SethLibrary is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2015
    Posts
    1

    Question Ignoring articles when sorting

    I have a database of books . In the field for titles How can I get access to ignore articles at the beginning of the titles such as "the" "A" and "An". For example instead of Access sorting on the word "The" in The Raven, I want it to sort on "Raven".



    Thanks for your help and patience

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 64bit Access 2013
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    I would do my sorting in a query. I would add a Field to the query with an expression that trims the "The", "A" or "An" and sort on this column/Field. Make the new field hidden by unchecking the display checkbox in the query design mode. Your expression will probably be an nested =IIF statement.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    Along the same line as Alan's thinking, you could have a table of "noise words" ---words that you don't want in your titles.
    Parse each Title, recording the book IBSN or whatever PK you use, then drop all the noise words. Save the revised/processed Title.
    If you want to find books by keyword (also eliminating Noise words), record the IBSN and each of the Keywords in the title.
    eg
    IBSN 3456789 --original title The Immortal Life of Henrietta Lacks

    ----noise words a, an, as, the, of, in, on, by, for, with, to, from, that, which, who.........
    ----keywords: Immortal Life Henrietta Lacks


    In a keyword search of tblKeyWordsByIBSN (1 to Many ; IBSN : Keyword in Title)

    3456789 Immortal
    3456789 Henrietta
    3456789 Lacks
    3456789 Life

  4. #4
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,830
    Per Alans suggestion, to remove the first noisewords for sorting in a query

    Code:
    SELECT *
    FROM tblBooks
    ORDER BY Replace(Replace(strConv(left(booktitle,4),3),"The ","",,1,Binary),"A ","",,1,Binary)
    Note the space after The and A (otherwise a book called "Theatre Magic" would end up as 'atre Magic')
    The 1 after the double comma limits the replace to the first one it finds
    the Binary makes it case sensitive - otherwise a book called "Minerva Conquests" would be become "Minerv Conquests" - may not matter for sorting purposes but up to you

    the strconv converts your book title to proper case for all words

    so this will 'catch' an incorrect case "a town called alice" would otherwise still be sorted on "a town called alice"

    However a book called "Winnie The Pooh" will be sorted on "Winnie Pooh". This also can be overcome if required by selecting the first say 4 characters (assuming 'The' is the longest word) and running the routine on that, but to prevent errors you would need to check there are at least 4 characters, then run the routine then add back the remaining characters, something like

    ORDER BY Replace(Replace(strConv(iif(len(booktitle)>4,left( booktitle,4),booktitle),3),"The ","",,1,Binary),"A ","",,1,Binary) & iif(len(booktitle)>4,mid(booktitle,5),"")

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    I agree with Ajax and Alan --- I was giving an approach if you have a long list of noise words.
    We did a similar thing with company names, product names, services names and had somewhere in the vicinity of 100 noise words Ltd, Limited,Inc, Incorporated, Pty, LLC etc .

    It's a common approach to use an "exclusion table" if you have a number of terms, names, people.... that you want to exclude from some process/query.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Compiler ignoring the with/Do in a loop?
    By tonygg in forum Programming
    Replies: 1
    Last Post: 10-13-2015, 05:26 AM
  2. Yesterday's Date ignoring weekends
    By coletteabrown in forum Access
    Replies: 4
    Last Post: 12-09-2013, 08:02 AM
  3. Sorting ignoring first letter of data?
    By lawmans3 in forum Queries
    Replies: 2
    Last Post: 04-01-2013, 06:31 AM
  4. ignoring null value in recordset
    By nickblitz in forum Access
    Replies: 10
    Last Post: 11-16-2012, 02:38 AM
  5. VBA excluding (Ignoring) Comma
    By RedWolf3x in forum Programming
    Replies: 3
    Last Post: 11-11-2011, 05:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums