+ Reply to Thread
Results 1 to 5 of 5

Populate Userform With Listbox Search Result

  1. #1
    Registered User
    Join Date
    02-20-2020
    Location
    Home, USA
    MS-Off Ver
    365
    Posts
    6

    Populate Userform With Listbox Search Result

    I have a userform (UserForm1) to add information to a database (Log). I created an advanced search for searches where there could be more than one result. Selecting the advanced search opens a 2nd userform (UserForm2) that contains a listbox for the search results. All of this works perfectly so far. What I want to happen is to select a result from the listbox and have all the information from that record displayed on the original userform (UserForm1). However, there are 34 columns of information that make up a single record. The listbox only contains 2 columns of information with the value in the first column being the unique identifier for the record. After many days of reading various forums I have been unsuccessful in making this happen. Could anyone help me?
    Attached Files Attached Files

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,209

    Re: Populate Userform With Listbox Search Result

    Please give instructions for how to use your file up to the point where you can select a record in the listbox, and what action you would want to take to load the other form.

    Roughly just based on your description, you have two options. One is to use the selection to search for the data in a worksheet then load all the data into the form from there. The other one is to update your listbox to have 32 hidden columns and take the data directly from there when the item is selected.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,027

    Re: Populate Userform With Listbox Search Result

    Here are a few pointers...See attached sample file...
    Instead of having code to populate Comboboxes...Rather store data in a hidden sheet and populate as follows...
    Please Login or Register  to view this content.
    I would neaten up your Userform Interface and keep the control numbering in order...For easy looping etc etc...
    I would keep the Search functionality on the same Form...No need for 2 forms...
    Select search criteria and then start typing in search box...Listbox will retain all valid searches...
    Double click on item in listbox and boxes above will populate...

    On opening of file click button above...This was just for testing purpose...Code can be place in an Auto_Open module...

    Anyway...Food for thought...Good luck...Happy Coding...
    I am sure others will hop on board and offer more valuable advice...
    Attached Files Attached Files
    Last edited by Sintek; 02-01-2022 at 04:40 AM.
    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 [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,527

    Re: Populate Userform With Listbox Search Result

    You already have a code to search for NCR so I kept to the original as much as possible.

    I only restiled your search function to use AdvancedFilter instead of searching cells 1 by 1.

    So open Advanced search, type item nr to search for, select item in Listbox.
    Attached Files Attached Files
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  5. #5
    Registered User
    Join Date
    02-20-2020
    Location
    Home, USA
    MS-Off Ver
    365
    Posts
    6

    Re: Populate Userform With Listbox Search Result

    Thanks to all that have replied. I'm at my place of employment and IT security is pretty tight so I can't look at any examples of what has been done. I will look at them tonight when I get home. Thanks for the help.

+ 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. [SOLVED] ListBox to populate UserForm trouble with same search criteria
    By chriswhite1982 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-10-2014, 01:46 AM
  2. [SOLVED] Item in ListBox (search) to populate UserForm with values
    By onmyway in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-12-2013, 04:47 AM
  3. [SOLVED] Populate a Listbox in a UserForm based on a Search Result
    By clapforthewolfman in forum Excel Programming / VBA / Macros
    Replies: 29
    Last Post: 07-17-2013, 07:53 PM
  4. VBA - Populate Listbox based on value selected in another ListBox (On Userform)
    By raaboo in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-12-2012, 11:18 AM
  5. Populate a Userform from a selection on a popup search listbox
    By ahmadassaad in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 10-16-2012, 09:00 AM
  6. Userform populate listbox with search from multiple textboxes
    By chendysworld in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-12-2012, 11:12 AM
  7. Populate userform listbox based on value selected in another listbox
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-07-2012, 05:16 PM
  8. how to populate Listbox on userform
    By kmsoni in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-22-2011, 02:13 PM

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