+ Reply to Thread
Results 1 to 13 of 13

Item in ListBox (search) to populate UserForm with values

  1. #1
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Item in ListBox (search) to populate UserForm with values

    Hi all,

    I would appreciate some help (again)!

    I would like to combine 2 functions.

    I have a Search feature that updates a ListBox with possible matches as you type. I would like the following to happen when you dbl click a record in the ListBox: It populates the UserForm with the data of that specific row in your sheet.

    Here is my code for the Search feature (works):

    Please Login or Register  to view this content.
    Here is my code for dbl click of item in the ListBox that is to populate my UserForm (doesn't work):

    Please Login or Register  to view this content.
    Thank you all!
    Attached Files Attached Files
    Last edited by onmyway; 08-02-2013 at 06:29 AM. Reason: Made changes

  2. #2
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Item in ListBox (search) to populate UserForm with values

    Any help, please

  3. #3
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Item in ListBox (search) to populate UserForm with values

    I hope you had a refreshed weekend, and feel motivated to assist me with tackling this issue!

    I am yet to make progress on this issue......

  4. #4
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Item in ListBox (search) to populate UserForm with values

    Hi..

    I had a quick look.. maybe this might help..

    1. You have duplicate values in Column A... it might be better to make it so the Listbox is filled with only Unique items.

    Try this code.. it uses the value from the Listbox as an autofilter Criteria.. then all you need to do is extract the values form the correct cells and place them in into your textboxes..

    I have done the first 2 for you.. that should give you an idea...

    Please Login or Register  to view this content.
    You will need to add this UDF into a Module (it finds the first Visible row after autofilter)..

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Try adding a column to the listbox for the row numbers.
    If posting code please use code tags, see here.

  6. #6
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Item in ListBox (search) to populate UserForm with values

    Hi apo and Norie, sorry for the belated response - I have had a hectic week thus far! Thanks for your input - I like the functionality!

    What I want to use the Search function for, a) is to check that one does not create/capture a duplicate record, AND, b) if one wants to do a search to edit an excising record.

    Could you perhaps assist in this: when I search and find the record I would like to edit, to update the UserForm, and the changes you make to the record, saves to the changes to the specific row for that record?

    I know we are halfway there! Thanks a lot!

    PS: Is it possible to change the code that it does not filter the data sheet? That it only updates the UserForm, and everything happens there as well? I don't want people to get confused when capturing records! They only need to capture, search, print etc....using ONLY the UserForm,
    Attached Files Attached Files
    Last edited by onmyway; 08-08-2013 at 08:18 AM. Reason: add workbook

  7. #7
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Item in ListBox (search) to populate UserForm with values

    Hi guys, would appreciate some input. I have uploaded my workbook on previous post. Post #6 contains what I would like to achieve.

    Thank you all!

  8. #8
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Item in ListBox (search) to populate UserForm with values

    Hi..

    So basically.. you want to update each rows cells with the values entered into the Userform for any existing GUID?

    That should be just a matter of inserting the values in the first visible row after auto filter..

    The Workbook you attached has most of the Userform values getting inserted into the incorrect cells..

    Example.. the Userform "Company" field is being inserted into the "Site" column.. and most others are jumbled up also..

    Try fixing those field allocations first and reattach your Workbook.. it adds a layer of confusion when testing when all the fields are not populating with the correct data.

  9. #9
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Item in ListBox (search) to populate UserForm with values

    hey apo. I have updated the form with correcting fields now being updated.

    "So basically.. you want to update each rows cells with the values entered into the Userform for any existing GUID?"

    Yes. This is to serve as a "database maintenance" feature, or for corrections.

    One thing; will it be possible to remove or switch "on" and "off" the auto filter when one has finished with a search and update of a row? i.e. when one is not searching or has finished searching, the whole database is visible without a filter?

    thanks!
    Attached Files Attached Files

  10. #10
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Item in ListBox (search) to populate UserForm with values

    Hi..

    Try the attached file..

    The correct record now gets updated.. you nearly had it right.. just needed to find the first visible row after autofilter..

    One thing; will it be possible to remove or switch "on" and "off" the auto filter when one has finished with a search and update of a row? i.e. when one is not searching or has finished searching, the whole database is visible without a filter?
    Adding this..
    Please Login or Register  to view this content.
    to your "Save" button, "Clear" button and "Close" button sorted that out..
    Attached Files Attached Files

  11. #11
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Item in ListBox (search) to populate UserForm with values

    apo, you rock! thanks!

    yet one more thing (I know, I know!): When one search and there is NO possible match, how can I get a msgbox to pop-up with the option: "Create new record?" using vbYes and "Continue your search?" for vbNo?

  12. #12
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Item in ListBox (search) to populate UserForm with values

    Hi..

    Add this..
    Please Login or Register  to view this content.
    directly below your Dim statements in your ListBox3_DblClick code..

    That will stop the error if you double click on empty space..

    When one search and there is NO possible match, how can I get a msgbox to pop-up with the option: "Create new record?" using vbYes and "Continue your search?" for vbNo?
    I don't see the point in that.. the Listbox populates with possible matches.. so if there are none.. all the User has to do is press the Clear button and enter a new record or type a new search criteria in the textbox..

  13. #13
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Item in ListBox (search) to populate UserForm with values

    Thanks.
    I don't see the point in that.. the Listbox populates with possible matches.. so if there are none.. all the User has to do is press the Clear button and enter a new record or type a new search criteria in the textbox..
    Make sense to you and me, but end users..... I will just train them properly!

    thanks for all your 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] 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
  2. 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
  3. 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
  4. 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
  5. Populate ListBox Based On Item Chosen In Another ListBox
    By davemojo82 in forum Excel General
    Replies: 1
    Last Post: 08-04-2009, 08:39 AM

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