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

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,616
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
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.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
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:
Upvote 0
Thanks so much My Answer Is This for your suggestion. Regrettably, I'm still getting an "Object required." error with that line.
 
Upvote 0
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:
Upvote 0
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
 
Upvote 0
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.
Note RoryA and myself also spent a fair bit of time on this issue at this MrExcel thread as well.
 
Upvote 0
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.
 
Upvote 0
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:
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,148
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top