Results 1 to 2 of 2
  1. #1
    RonL is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2009
    Location
    NJ
    Posts
    114

    Sorting by alphanumeric field

    Hello. Novice question, if I may. I'm still contemplating my design, so not sure if this is a simple question.



    I will have an app where the user will be entering records (to a single table) via a datasheet on a form. The datasheet will be ordered by a text field, call it txtMySequence, which will consist of a five character string. The first four characters will be numerals, the fifth will be a blank, except when the user wishes to "insert" a record into the list of existing ones. For such insertions he wants txtMySequence to be incremented alphabetically. For example if the preceding record has txtMySequence = "1234 " the "inserted" record would have the value "1234a" and so forth. In other words, any record "inserted" after the initial dataset is entered, should be suffixed with a letter character but remain displayed just beneath the record that was current at the time of the "insertion."

    I've been working out ideas for the VBA functions I'll need to automate the construction of txtMySequence, but I'm not sure how to sort on it. I suppose I could arrange it so that txtMySequence is actually a composite of two hidden fields, one containing the numeric characters and the other the alphabetic suffix. Then sorting would be done on those fields. Or I guess i could have a (hidden) numeric field whose sole purpose is to define the sort order - though I'd have to figure out how to renumber all records "beneath" an inserted one. (Obviously, simple autonumbering won't work, since the desired display order is not the record creation order.)

    I was wondering if there's a standard - or simpler - approach to this sort of thing. Suggestions would be appreciated. (I'm using Access 2010 under Win7x64, but the user will be operating only in the run time environment - ie. I want to compile the app.)

    Thanks in advance, -Ron

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    There is no 'standard' approach. Here is how I handle generating unique ID with code https://www.accessforums.net/forms/a...ing-23329.html

    More references in https://www.accessforums.net/access/...ers-21361.html
    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.

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

Similar Threads

  1. Replies: 8
    Last Post: 04-17-2012, 01:37 PM
  2. alphanumeric primary key
    By slimjen in forum Database Design
    Replies: 4
    Last Post: 09-18-2011, 10:20 PM
  3. Field Sorting on Reports
    By netchie in forum Access
    Replies: 5
    Last Post: 07-25-2011, 11:45 AM
  4. Format a field(AlphaNumeric)
    By Bakar in forum Database Design
    Replies: 1
    Last Post: 12-20-2010, 06:36 AM
  5. sorting a field in report
    By Philangr8 in forum Reports
    Replies: 3
    Last Post: 08-26-2009, 05:38 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