Results 1 to 3 of 3
  1. #1
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209

    Sort a Text Field Chronological

    This may not be possible but thought I would ask. I have a field that is a text field (called UserInfo), and it shows a name and a date for example, Jose 08142012 then the next entry would be George 22211. However some entries may not actually have a date at the end they may just be a name. Is it possible for me to sort UserInfo chronologically so that all the dates are sorted in ascending order? I was thinking maybe to use an access function to strip out the date and place that in a field by itself and then sort that ascending, but IDK how to do that either! haha. All input is greatly appreciated.


    EDIT:


    I thought I would get creative and try:
    Code:
    Right(UserInfo, 6)
    but now I see that sometimes there are hyphens or dashes in the date, so that throws my entire theory. Is there a way to return anything after a space?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    This is bad data structure. Is this data you receive periodically from external source? How many records are involved?

    The two parts can be split.

    To get the name part:
    Left(UserInfo, InStr(UserInfo," "))

    To get the date part:
    Mid(UserInfo, InStr(UserInfo," ")+1)

    Programmatically converting the date string to a date value would require complex VBA function because of the inconsistent structure.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209
    It is a linked SQL Table into access there are about 40,000 records in the table, and yes it was received from an outside source. I was thinking adding a new field to the table with the two split so it would be easier to sort (and you just confirmed it). now as far as the query goes, it *should* return less than 1k results due to extra parameters being added into the query.

    Also the Mid Function above works perfectly, thank you thank you!

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

Similar Threads

  1. Button to Sort by Field
    By tylerg11 in forum Programming
    Replies: 4
    Last Post: 10-20-2011, 02:43 PM
  2. Chronological Query/Report
    By Benjamin Breeg in forum Queries
    Replies: 6
    Last Post: 09-23-2011, 06:17 PM
  3. Access ADP Form Sort on ComboBox Text
    By bo_dong in forum Forms
    Replies: 5
    Last Post: 04-20-2011, 10:27 AM
  4. Sort according to field length?
    By wawinc in forum Queries
    Replies: 4
    Last Post: 12-15-2010, 04:27 PM
  5. Replies: 2
    Last Post: 05-05-2010, 02:52 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