Results 1 to 10 of 10
  1. #1
    MishaLjusha is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2017
    Posts
    8

    How to get index of last entered item in sorted combo box (row source = query)

    Hello. First time on any forum.



    With NotInList event I'd like to add "new item" to combo box and select it programmaticaly like [Forms]![frmform2]![cboCombo0].Selected(n) = true. Where n should be the index of last entered item. I have resolved the problem until combo is sorted on unbound column.

    As I need the combo to be sorted (unbound column are Last names, so I'd like to have them sorted ascending) and the last entered item gets "to me unknown" index I need some help on this metter.

    Or maybe in other words:

    Instead of [Forms]![frmform2]![cboCombo0].Selected(3) = true to have it in some way like [Forms]![frmform2]![cboCombo0].Selected("joe") = true.

    Any help possible, PLEASE

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    IF the cboBox is bound to the name field, then use:
    cboBox='Joe'

    It's will automatically select. But not for multi selects.

  3. #3
    MishaLjusha is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2017
    Posts
    8
    No. Combo box is bound to ID of "Joe".

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Then you must assign the index,
    cboBox=9
    then Joe will show.

  5. #5
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    If you're wanting the index number of the last item entered right after it was entered (which means you can't assign it) you can get the index number of the list item if the last item entered becomes the chosen value. You don't say whether or not it is. So if you had MsgBox Me.cboCombo0.ListIndex you'd see the zero based index number of the selected item. This could be in AfterUpdate or DblClick event
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430

  7. #7
    MishaLjusha is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2017
    Posts
    8
    Ajax, thanks for the Excelguru.ca link. As I mentioned, this is my first forum ever and I don't know the "rules" of "foruming". So every help is much appreciated. I Will do it correctly next time. Regarding my thread I Will check your solution during the day. Thanks again

  8. #8
    MishaLjusha is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2017
    Posts
    8
    Can I send you (maybe by mail) my sample database (it is very small, 800 kb) to show you exactly what my problem is?
    Maybe my line of thinking is absolutely wrog or I can't exactly explain what my problem is.
    Thanks in advance

  9. #9
    MishaLjusha is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2017
    Posts
    8
    Ok. I understand that. But how do I get the 9 if I don't know the position of new item in sorted combobox dropdown list

  10. #10
    MishaLjusha is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2017
    Posts
    8
    Ok. Finnaly I got it.
    Solved in a manner like Combo0 =DMax("[ID]";"tblNames")

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

Similar Threads

  1. Replies: 1
    Last Post: 03-21-2018, 03:32 PM
  2. Replies: 5
    Last Post: 07-29-2014, 09:18 AM
  3. Replies: 9
    Last Post: 02-26-2013, 10:48 AM
  4. The text you entered isn't an item in the list
    By mariusvdw in forum Access
    Replies: 3
    Last Post: 05-09-2012, 11:31 AM
  5. Bound Object Frame Combo sorted Results
    By kevsim in forum Programming
    Replies: 7
    Last Post: 01-08-2011, 06:30 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