+ Reply to Thread
Results 1 to 6 of 6

Userform selection yields wrong information

  1. #1
    Forum Contributor
    Join Date
    07-30-2017
    Location
    texas
    MS-Off Ver
    2016
    Posts
    123

    Userform selection yields wrong information

    Greetings everyone!

    I have a problem and I was hoping for some help from the guru's.

    I have a workbook (see attachment) with a searchable userform. The problem I am having is that when there is multiple entries of the same persons name and a selection is made from the listbox, the wrong line is displayed in the fields below. I believe the selection is only pulling the first entry in the list, no matter which entry is selected. Any suggestions as to how i could modify the code so that the correct details are pulled into the textboxes? Thanks in advance for any help you can offer.


    Problem can be created by: 1. search for the name "David". A list of four entries will appear. 2. Double click on the second, third or fourth line and you will see that the textboxes do not pull the correct date among other fields.


    The rest of the form works beautifully.


    Any help would be appreciated!


    Sincerely,

    David
    Attached Files Attached Files

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Userform selection yields wrong information

    Hi there,

    Nice UserForm!

    It's a bit complicated so I've had just a very quick look at it, but it seemed to work correctly for me when I changed the TDCJ # field to unique values - in your post all of the records for David Oney contain a value of 123456789 for the TDCJ # field.

    Hope this helps.

    Regards,

    Greg M

  3. #3
    Forum Contributor
    Join Date
    07-30-2017
    Location
    texas
    MS-Off Ver
    2016
    Posts
    123

    Re: Userform selection yields wrong information

    Thanks Greg!

    The problem is: the TDCJ# is unique to that person and must remain the same. There will be multiple entries of the same person(s) listed in the sheet.

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Userform selection yields wrong information

    So your problem is using a non-unique value for your search. I made a few changes. Your listbox did not specify the width for the last column, so I set it to 80, and added another 0 width column.

    ColumnWidth property for lstLookup now reads: 100 pt;60 pt;40 pt;80 pt;70 pt;80 pt;0 pt
    Then I added one line to your search button code:

    Please Login or Register  to view this content.
    This means that now you have the row number of the search results available to do your textbox updating. Which requires a change to the double-click event for your listbox (changed it as little as possible):

    Please Login or Register  to view this content.
    Last edited by Arkadi; 04-30-2019 at 09:17 AM.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  5. #5
    Forum Contributor
    Join Date
    07-30-2017
    Location
    texas
    MS-Off Ver
    2016
    Posts
    123

    Re: Userform selection yields wrong information

    Beautiful solution. I just did not have the smarts to do it. That is why I lean on the "Gurus" to teach me. Thanks for all your help!

  6. #6
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Userform selection yields wrong information

    Glad we could help darbar76528
    Thanks for the rep and the kind comments. If I could ask a favour, please remember to mark the thread as solved? Thank you!

+ 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. Get Multi Selection Listbox userform and clear all selection
    By jp16 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-30-2018, 10:43 AM
  2. [SOLVED] Userform ComboBox selection not displaying on first attempted selection
    By yachrishere in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-01-2016, 07:44 PM
  3. UserForm ComboBox selection to activate WorkSheet selection row.
    By excelV3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-24-2015, 12:35 PM
  4. [SOLVED] Filtering more information via criteria selection on userform
    By nikadon in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-21-2013, 09:35 PM
  5. [SOLVED] Userform Combobox selection populates wrong data in the textboxes
    By yahya263 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-02-2013, 09:46 AM
  6. Userform that duplicates Information and places in correct sheet depending on selection
    By ExcelHacks_99 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-18-2013, 03:38 PM
  7. auto sum yields wrong number
    By Jeroen1000 in forum Excel General
    Replies: 5
    Last Post: 10-19-2009, 05:59 AM

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