+ Reply to Thread
Results 1 to 9 of 9

Combobox automatically reposition ListIndex

  1. #1
    Registered User
    Join Date
    02-19-2017
    Location
    Adelaide, Australia
    MS-Off Ver
    16
    Posts
    19

    Combobox automatically reposition ListIndex

    Hi, I have situation with 2 user forms - A calls B. Form A just list records, and form B is called to edit single record. Data comes from the database. Simple, works well.
    One of the fields is called colour_id and user picks it value from the combo box, which shows 2 columns - colour_id and colour_name, bound to column 1 - colour_id.
    As I'm passing colour_id from form A to form B, I want combobox to automatically reposition and show me matching colour_name.

    Instead, what happens is that, combo box shows me my colour_id, and then I need to programatically reposition it to matching colour name.
    My question is - shouldn't this happen automatically like in Access for example?

    Cheers
    Jack
    Last edited by jacknomiz; 04-03-2017 at 12:09 AM. Reason: more descriptive title

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Combobox

    Hi jacknomiz

    Please attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE and an AFTER result to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Combobox

    Tell me jacknomiz

    Any reason why you are using 2 userforms calling the same information. Why not just one and combine the required info as per sample.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    02-19-2017
    Location
    Adelaide, Australia
    MS-Off Ver
    16
    Posts
    19

    Re: Combobox

    Hi Sintek, thanks for your post.

    In your example - userform with colour selection combo, how would you pass colour number (eg 4) to the form, and then have the combo box display Green inside it, not in another textbox?
    I found only 1 way to do it- on form activate programatically loop through all colours in combobox and do me.combobox.listindex when match found.

    I thought that once you pass #4 to the combo box, it will be smart enough to show me Green automatically?

    I need to have 2 forms - one is read only view of the table, then you double click and another form comes up listing selected record and allowing you to edit it.

    Cheers

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Combobox

    thanks for the title change
    Last edited by FDibbins; 04-03-2017 at 12:14 AM.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Combobox automatically reposition ListIndex

    Hi Jacknomiz

    Upload a sample workbook so that we can see the result required.
    If you select [4] do you want another combobox to display green..
    Why would you want to read the Table in a userform when the Table is displayed in your sheet.
    As per sample you select [4] from ComboBox dropdown list. This then displays [4] in textbox1 and [Green] in Textbox2...You can then edit textbox1 and textbox2 and have a button that makes the changes to the Table.

  7. #7
    Registered User
    Join Date
    02-19-2017
    Location
    Adelaide, Australia
    MS-Off Ver
    16
    Posts
    19

    Re: Combobox automatically reposition ListIndex

    Yes that will work too. Many thanks man.

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Combobox automatically reposition ListIndex

    Here you go...play around with this.
    If you want to edit, select choice from combobox and change colour in textbox2 then press edit.
    If you want to add, make sure all boxes are clear, enter a no into textbox1 and a colour into textbox2 then press add.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    02-19-2017
    Location
    Adelaide, Australia
    MS-Off Ver
    16
    Posts
    19

    Re: Combobox automatically reposition ListIndex

    Great work Sintek, many thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. ComboBox values source being changed based on another combobox selection in a UserForm
    By stephenanderson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-08-2016, 11:12 PM
  2. [SOLVED] Code required to Auto Populate 3rd Combobox based on 02nd Combobox Selection
    By bimmy80 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-14-2015, 03:56 AM
  3. [SOLVED] Change next ComboBox list based on previous ComboBox selection
    By SteveTheFish in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-26-2015, 11:23 PM
  4. Replies: 1
    Last Post: 11-07-2014, 01:21 PM
  5. Userform Combobox to populate form: Can I change the order of the columns in the combobox?
    By CraigWiggins in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-31-2014, 12:14 PM
  6. [SOLVED] Make combobox list options dependant on selection in another combobox within a userform
    By Vladimir_Dobvchenko in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-23-2013, 05:30 AM
  7. [SOLVED] Excel Userform: Populate other controls (i.e. textbox & combobox) based on combobox select
    By MileHigh_PhD in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-22-2013, 04:50 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1