Results 1 to 5 of 5
  1. #1
    twildt is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    56

    Combo Box - Custom Sort Order


    I have a combo box with the following entries:

    Document
    Other
    Process
    Validate
    Verify

    I want the list sorted so that "Other" is at the bottom. Everything else is alphabetical ascending. Is this possible?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Add a 2nd virtual field in the query called SortOrder build it as:
    select *, [choice]<>'Other' AS SortOrder from tChoices Sort by [SortOrder]

    the selection OTHER value will show FALSE and sort to the bottom,

  3. #3
    dunc723 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Posts
    28
    Is your row source a table or query? If it does not have to be, a simpler way is to just put the choices in the Row Source property as text in the desired order, separated by semicolons: Document;Process;Validate;Verify;Other

  4. #4
    twildt is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    56
    what do you mean by "virtual" field?

  5. #5
    twildt is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    56
    Ok, here is what I came up with so far.

    1. I made a query that adds a calculated field.

    qry_SrtType
    ...SrtType
    ...WorkType

    Document 1
    Other 2
    Process 1
    Validate 1
    Verify 1

    SELECT IIf([Work Type]="Other",2,1) AS SrtType, [Work Type]
    FROM Work_Type;

    This works! The query in datasheet view is perfectly sorted!!

    2. I add the following code to my form's combo box
    SELECT [Work Type] FROM qry_SrtType ORDER BY SrtType, [Work Type];

    This is not working. The combo box is empty. I added that code above to the "Control Source" and I also tried the "Row Source".

    The Control Source used to be a field in a table because I need that table to update when a selection is made and the user hits the "Save" button.

    What am I doing wrong? Why is my list empty when the query works? And how can I set it up so that when the user hits save on the form it updates the table "Work Hours"?

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

Similar Threads

  1. Change Sort Order of Combo Box "On-The-Fly"
    By JoeM in forum Programming
    Replies: 6
    Last Post: 09-26-2013, 06:50 PM
  2. Sort order in a sub form
    By roar58 in forum Forms
    Replies: 1
    Last Post: 03-17-2012, 08:57 PM
  3. Replies: 1
    Last Post: 02-27-2012, 06:22 PM
  4. Replies: 0
    Last Post: 06-02-2011, 04:19 AM
  5. Sort Order Variation with nulls
    By jonsuns7 in forum Queries
    Replies: 1
    Last Post: 10-09-2009, 03:10 AM

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