Results 1 to 5 of 5
  1. #1
    wawinc is offline Novice
    Windows 7 Access 2007
    Join Date
    Dec 2010
    Posts
    5

    Sort according to field length?


    Is there a way to sort according to field length or number of characters in a note/memo field?

    I'm hoping to sort descending so the longest memos appear first...

  2. #2
    William McKinley is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    59
    Try this:

    Code:
    SELECT Table.YourField, 
    FROM Table
    ORDER BY Len(YourField) DESC;

  3. #3
    ConneXionLost's Avatar
    ConneXionLost is offline Simulacrum
    Windows XP Access 2003
    Join Date
    Jan 2010
    Location
    Victoria, Canada
    Posts
    291
    add a calculated field to the query that counts the number of characters, like:

    Code:
    fieldlength: Len([yourfield])
    then sort on that field.

  4. #4
    wawinc is offline Novice
    Windows 7 Access 2007
    Join Date
    Dec 2010
    Posts
    5
    Quote Originally Posted by William McKinley View Post
    Try this:

    Code:
    SELECT Table.YourField, 
    FROM Table
    ORDER BY Len(YourField) DESC;
    Perhaps I am too much of a newbie to be in this forum. How do I use code?

    My best guess'd be:
    Database Tools> Visual Basic> File> New?

    Saving it, applying it, and deleting it if it doesnt work - all easy/intuitive, I presume?

    If there is some sort of How to on this stuff I'm happy to do it...

    Thanks!
    Last edited by wawinc; 12-15-2010 at 03:15 PM. Reason: clarification

  5. #5
    William McKinley is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    59
    This would be achieved by using a query. Here's an article that explains the basics of queries: http://office.microsoft.com/en-us/ac...010209892.aspx

    Create Tab on the Ribbon > Query Design, don't add any tables > Click SQL View > Paste the code below with your field names > Run

    Code:
    SELECT YourFieldNameHere
    FROM YourTableNameHere
    ORDER BY Len(YourFieldNameHere) DESC

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

Similar Threads

  1. Convert number to fixed length text field
    By tpcervelo in forum Queries
    Replies: 1
    Last Post: 08-02-2010, 07:26 PM
  2. Replies: 6
    Last Post: 04-30-2010, 01:57 PM
  3. Macro Button to Sort Field A-Z
    By rdirosato in forum Access
    Replies: 1
    Last Post: 03-11-2010, 10:32 PM
  4. How to sort by three sort orders
    By captgnvr in forum Access
    Replies: 4
    Last Post: 11-09-2009, 07:30 AM
  5. Replies: 1
    Last Post: 06-01-2009, 04:05 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