Results 1 to 4 of 4
  1. #1
    Heezea is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Nov 2013
    Posts
    3

    Rank / move combo box with adjacent arrow button

    Hey guys, I've done several google searches and forum searches, but I can't find any question similar to mine though I'm sure it's been asked before.

    My question is:
    How do you add buttons (up/down arrows) that are tied to combo boxes and would make the combo box move up or down, thereby changing the order of the item in the combo box.

    As an example:


    Before
    1 Dogs (arrow up) (arrow down)
    2 Cats (arrow up) (arrow down)

    *Press arrow up for cats*
    After:
    1 Cats (arrow up) (arrow down)
    2 Dogs (arrow up) (arrow down)

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    This is changing the Order By clause of the RowSource.

    Put up/down toggle or radio buttons in an Option Group control.

    Then in the AfterUpdate event of Option Group control, something like:

    Me.combobox.RowSource = "SELECT fieldname FROM tablename ORDER BY fieldname " & IIf(Me.Option=0, "Ascending", "Descending") & ";"
    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
    Heezea is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Nov 2013
    Posts
    3
    Could anyone else offer a bit more input here please? I've tried some of the initial steps recommended, but still having a bit of a hard time grasping it all.

    Do the rows I want to move need to become part of the Option Group?
    When I put in the code
    Code:
    Me.combobox.RowSource = "SELECT fieldname FROM tablename ORDER BY fieldname " & IIf(Me.Option=0, "Ascending", "Descending") & ";"
    it is giving me an error. I looked at the microsoft coding guides but I'm having a hard time with the correct form.

    Thanks for any additional help.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Nothing wrong with the syntax. I seem to have misunderstood your request. What I suggested only switches the sort order of the list between ascending and descending. Moving a single item would be far more complicated. Why would you want to?

    Use your combobox name and your fieldname and your option group name. I don't know those so I just used a generic "combobox" and "fieldname" and "Option".

    Do you know how to build an Option Group control?
    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: 2
    Last Post: 02-08-2014, 07:10 PM
  2. Replies: 5
    Last Post: 11-06-2013, 02:49 PM
  3. Replies: 6
    Last Post: 01-24-2013, 03:15 PM
  4. Need to detect right arrow key
    By ChuckColeman1812 in forum Programming
    Replies: 4
    Last Post: 09-12-2012, 08:08 AM
  5. Replies: 5
    Last Post: 04-19-2012, 10:41 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