Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: 'Object Required' error Trying To Populate Textbox In One Userform With The Selected Value From Listbox in Second Userform (Xposted)
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Apr 2005
    Location
    Ontario, Canada
    Posts
    3,182
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default 'Object Required' error Trying To Populate Textbox In One Userform With The Selected Value From Listbox in Second Userform (Xposted)

    I have hit a roadblock in the progress of my VBA project. I am reaching out to a second group of pros to see if perhaps they have a solution after having limited success where I had originally posted my question.

    I have two open userforms. userform1 (uf3_group_1) has a textbox (textbox1) in which I am trying to populate from the listbox (miss_rn) selection from userform2 (miss_rn).

    I am failing with this line in the initialization code of userform1.
    Code:
    TextBox1.Value = test_mr.miss_rn.ListIndex
    This attempt also failed.
    Code:
    TextBox1.Value = test_mr.miss_rn.List(.ListIndex, 1)
    I am getting an "Object required." error.

  2. #2
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,887
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

    Default Re: 'Object Required' error Trying To Populate Textbox In One Userform With The Selected Value From Listbox in Second Userform (Xposted)

    If like you said it would be part of the initialize code when Userform 1 is opened it would need to look something like this.

    Code:
    Private Sub UserForm_Initialize()
    'Modified  5/12/2019  7:58:14 PM  EDT
    TextBox1.Value = UserForm2.ListBox1.Value
    End Sub
    This assumes Userform with listbox is open and some value in the listbox is selected.
    Last edited by My Aswer Is This; May 12th, 2019 at 09:03 PM.
    Be sure and always test this script on sample data the first time you use this as to avoid any problems with your data. Always trying to learn more and help others where I can. I'm using Excel 2013.
    Patience please I知 not perfect yet. "Memories are forever"

  3. #3
    Board Regular
    Join Date
    Apr 2005
    Location
    Ontario, Canada
    Posts
    3,182
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: 'Object Required' error Trying To Populate Textbox In One Userform With The Selected Value From Listbox in Second Userform (Xposted)

    Thanks so much My Answer Is This for your suggestion. Regrettably, I'm still getting an "Object required." error with that line.

  4. #4
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,887
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

    Default Re: 'Object Required' error Trying To Populate Textbox In One Userform With The Selected Value From Listbox in Second Userform (Xposted)

    I assume you know I used default names for the two UserForms
    You will need to modify to your needs.
    And modify the listbox name to your needs
    And the Textbox name




    How are you opening these Userforms.

    Show me the entire code your using to open both of these Userforms.
    Last edited by My Aswer Is This; May 12th, 2019 at 11:03 PM.
    Be sure and always test this script on sample data the first time you use this as to avoid any problems with your data. Always trying to learn more and help others where I can. I'm using Excel 2013.
    Patience please I知 not perfect yet. "Memories are forever"

  5. #5
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,887
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

    Default Re: 'Object Required' error Trying To Populate Textbox In One Userform With The Selected Value From Listbox in Second Userform (Xposted)

    I'm just curious. Why do you need more then one UserForm?

    I have used UserForms for years and never needed more then One.

    Do you know about UserForm Multipages
    Be sure and always test this script on sample data the first time you use this as to avoid any problems with your data. Always trying to learn more and help others where I can. I'm using Excel 2013.
    Patience please I知 not perfect yet. "Memories are forever"

  6. #6
    Board Regular
    Join Date
    Jul 2007
    Location
    Sydney
    Posts
    4,411
    Post Thanks / Like
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)

    Default Re: 'Object Required' error Trying To Populate Textbox In One Userform With The Selected Value From Listbox in Second Userform (Xposted)

    Note RoryA and myself also spent a fair bit of time on this issue at this MrExcel thread as well.

  7. #7
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,887
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

    Default Re: 'Object Required' error Trying To Populate Textbox In One Userform With The Selected Value From Listbox in Second Userform (Xposted)

    I see now the other posting. Now this sounds like the two UserForms are not both in the same Workbook. I see no mention of this in this post. I may have helped on this prior myself I loose track sometimes.
    Quote Originally Posted by Trebor76 View Post
    Note RoryA and myself also spent a fair bit of time on this issue at this MrExcel thread as well.
    Be sure and always test this script on sample data the first time you use this as to avoid any problems with your data. Always trying to learn more and help others where I can. I'm using Excel 2013.
    Patience please I知 not perfect yet. "Memories are forever"

  8. #8
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,887
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

    Default Re: 'Object Required' error Trying To Populate Textbox In One Userform With The Selected Value From Listbox in Second Userform (Xposted)

    I have not tested this.
    But if your two Userforms are on different Workbooks then I would say you would need to refer to the workbook also

    Something like Workbooks("Jane.xlsm").UserForm1.TextBox1.value=Workbooks("Paul.xlsm").UserForm3.Listbox1.value

    And both Workbooks would need to be open.
    Be sure and always test this script on sample data the first time you use this as to avoid any problems with your data. Always trying to learn more and help others where I can. I'm using Excel 2013.
    Patience please I知 not perfect yet. "Memories are forever"

  9. #9
    Board Regular
    Join Date
    Jul 2007
    Location
    Sydney
    Posts
    4,411
    Post Thanks / Like
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)

    Default Re: 'Object Required' error Trying To Populate Textbox In One Userform With The Selected Value From Listbox in Second Userform (Xposted)

    Maybe send the desired value from userform2 to a cell in the workbook that has userform1 and then have the textbox in userform1 reference that cell in its own workbook. Would be a lot easier then trying to reference a control I would imagine.

    Note this has been cross-posted here
    Last edited by Trebor76; May 13th, 2019 at 01:52 AM.

  10. #10
    Board Regular
    Join Date
    Apr 2005
    Location
    Ontario, Canada
    Posts
    3,182
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: 'Object Required' error Trying To Populate Textbox In One Userform With The Selected Value From Listbox in Second Userform (Xposted)

    The reason for so many userforms ... this is not one application. The main application relies of upwards of 3 different workbooks that hold dynamic data day by day. Each workbook has its own set of forms that allow users to access and manipulate data unique to that database. This allows data to be worked on by users without tieing up access to the others. I can have users working on each database independently at the same time. With one workbook and with one userform, I can't allow multiple users to work with their assigned data.

    The main application ties all these unique and sometimes independent workbooks together. This master application, I am trying anyway, has access to the other workbooks userforms so that data can be accessed and manipulated from within.

    For example, one large database (workbook) is comprised of customer information. It has it's own forms unique to entering and manipulating data specific to customer information. Another workbook holds information specific to facility rentals and has no reliance on the customer data. It has it's unique forms. I can have two users working on each of these workbooks at the same time, whereas if it was one workbook, only one could be working on it at any given time.

    A third, and master application, ties the data from both the customer data and the facility rental data workbooks to create a specific document. There are times when working with this main application, data from the other workbooks is missing or incomplete as identified by the application. (eg encounters a missing customer record) When this happens, the idea is to be able to access that specific workbook's (customer) forms (using base data from the main application) to edit/enter that information. If the main application encounters missing data related to the customer, the user of the main application can edit this information throuhgh the customer workbook with the same userform that one would use when working with the customer workbook independently. It simply saves me having to recreate the same userform in the main application. The missing data is then maintained in the customer workbook, and made available in the master application as a result.

    Yes ... the data is interdependent, and I'm trying to establish access to all through one master application without having to recreate userforms. The databases are fairly large, so trying to maintain them all in one workbook makes for a large slow file, as well as removes the ability to work on different databases independently.

    I think the easiest solution is to assign the value to a cell and access the cell rather than the object.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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