+ Reply to Thread
Results 1 to 13 of 13

Userform Find and Replace

  1. #1
    Registered User
    Join Date
    12-28-2006
    Posts
    97

    Userform Find and Replace

    I have attached my spreadsheet. What I am trying to do is to be able to search for data on the Data worksheet (to get to the user form I click the modify referral on the out worksheet). The code I have so far works but when I search for records that have duplicate "cmm" values it only fills in the first 10 fields on the form with the appropriate info. For example in the attached file if you click on the CMM text box and type in 6262 then find it comes up with 2 instances of 6262. but when you click on each individual record in the list box only the 1st 10 textboxes change with the appropriate info.

    Any Ideas why this is happening?
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    12-28-2006
    Posts
    97

    Re: Userform Find and Replace

    Here is my code for the userform.
    Please Login or Register  to view this content.

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485

    Re: Userform Find and Replace

    Because that is all the code is doing.
    Same is true for the Last button.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Userform Find and Replace

    Your listbox click event only specifies 10 controls to populate, hence it only does 10!
    Everyone who confuses correlation and causation ends up dead.

  5. #5
    Registered User
    Join Date
    12-28-2006
    Posts
    97

    Re: Userform Find and Replace

    But when I put in more then that I get an error. I will goback and do that then post the error

  6. #6
    Registered User
    Join Date
    12-28-2006
    Posts
    97

    Re: Userform Find and Replace

    So when I add this code I get a runtime error -2147024809 (80070057)
    Could not get the List Propert. Invalid Argument

    .TextBox11.Value = ListBox1.List(r, 10)

    Highlighted in yellow
    Please Login or Register  to view this content.

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485

    Re: Userform Find and Replace

    You listbox does not have that information in it.

    Try this approach instead. When doing the find store the Text and RowNumber in the listbox.
    Then when clicking the listbox use the RowNumber information to populate the textboxes.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    12-28-2006
    Posts
    97

    Re: Userform Find and Replace

    When I enter in your code I get a Run time error 13
    Type mismatch when I go to select the 2nd instance of 6262 with a yellow hightlight on the follow row.

    Please Login or Register  to view this content.

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485

    Re: Userform Find and Replace

    Works for me
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    12-28-2006
    Posts
    97

    Re: Userform Find and Replace

    You are Awsome. So how then do I fix the last and first commands to load the next record. For example when I click the arrows it will scrool though the data to the next record or previous record

  11. #11
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485

    Re: Userform Find and Replace

    Using the same approach only this time you need to find the last row number.

    To save duplicating the code create a routine for displaying a specified row of data. Then all you need to do is pass the range as an argument.

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    12-28-2006
    Posts
    97

    Re: Userform Find and Replace

    Let me first thank you for all your help and time. I am still having problems with the first and last buttons. when I click on them it is not scrolling to the next record just showing the same record 6262 which is neither the forst or last record so i am not sure how that is happening. Could it have somethign to do with thelist box. In your previous thread you hade the following code for the first button as
    Please Login or Register  to view this content.
    but that will only display one particular row so I changed it to below but it still does not work correctly

    Please Login or Register  to view this content.

  13. #13
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485

    Re: Userform Find and Replace

    Your last and first seem to be the wrong way around.

    In the attached first/last works on the complete data set.
    If you want it to be the first/last based on the result of a find then you need to extract the row number from the 2 and last items of the listbox.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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