Results 1 to 5 of 5
  1. #1
    Ran is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    36

    Thumbs up Forms\VBA Code\Sort Combo Box

    Hello,

    If anyone can help, would be much appreciated!

    I need VBA code to insert into my form to sort my combo box in this order:



    1.BLANK OR NULL
    2.PENDING
    3.CODING REVIEW
    4.DEFERRED
    5.BILLED

    Thank you in advance!

  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by Ran View Post
    Hello,

    If anyone can help, would be much appreciated!

    I need VBA code to insert into my form to sort my combo box in this order:

    1.BLANK OR NULL
    2.PENDING
    3.CODING REVIEW
    4.DEFERRED
    5.BILLED

    Thank you in advance!
    What is the row source for the combo box?

  3. #3
    Ran is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    36
    The row source is from a select query, filed name "TAR STATUS JS"

    The purpose of this field is for the user to use the Combo Box in the form to select what he/she has done to the account, which updates the query and main table with the drop down item they selected. All I want to do is have the query sorted or ordered by in particular order by what their selections, as I listed above.

    So basically either have a vba code ordered by in the form or a sql ordered by clause added to the query sql statement.

    Thanks!

  4. #4
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by Ran View Post
    The row source is from a select query, filed name "TAR STATUS JS"

    The purpose of this field is for the user to use the Combo Box in the form to select what he/she has done to the account, which updates the query and main table with the drop down item they selected. All I want to do is have the query sorted or ordered by in particular order by what their selections, as I listed above.

    So basically either have a vba code ordered by in the form or a sql ordered by clause added to the query sql statement.

    Thanks!
    OK, my mistake... What is the SQL of the row source for the combo box?

  5. #5
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by Ran View Post
    The row source is from a select query, filed name "TAR STATUS JS"

    The purpose of this field is for the user to use the Combo Box in the form to select what he/she has done to the account, which updates the query and main table with the drop down item they selected. All I want to do is have the query sorted or ordered by in particular order by what their selections, as I listed above.

    So basically either have a vba code ordered by in the form or a sql ordered by clause added to the query sql statement.

    Thanks!
    No VBA needed.

    In the table where the values are stored, add a field named "Seq" (what I use - but follow your naming convention), type Integer.
    Save the table.
    Open the table and enter 1, 2, 3, ... in the Seq field for the order you want for the values:

    Code:
    Desc                     Seq
    CODING REVIEW             3
    BLANK OR NULL             1
    PENDING                   2
    BILLED                    5
    DEFERRED                  4
    In the query "TAR STATUS JS" , add the field "Seq" to the design grid, set the SORT row to "Accending" and uncheck the check box in the SHOW row. Save the query. (BTW, it is not a good idea to use spaces in object names or special characters.)

    When you view the combo box options, they will be sorted.....
    Last edited by ssanfu; 03-15-2012 at 01:13 PM. Reason: spelling

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

Similar Threads

  1. Replies: 1
    Last Post: 02-09-2012, 08:43 PM
  2. filtering of combo box / vba code
    By Kotoca in forum Programming
    Replies: 2
    Last Post: 02-08-2012, 08:15 AM
  3. Replies: 3
    Last Post: 09-16-2010, 09:50 AM
  4. VBA code - questions table onto forms
    By Tman in forum Programming
    Replies: 3
    Last Post: 04-26-2010, 05:47 AM
  5. Sort Combo Box Contents
    By aputt@ssd.com in forum Programming
    Replies: 3
    Last Post: 12-03-2009, 04:47 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