'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
Apr 5, 2005
Messages
3,185
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.
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,046
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:

Ark68

Well-known Member
Joined
Apr 5, 2005
Messages
3,185
Thanks so much My Answer Is This for your suggestion. Regrettably, I'm still getting an "Object required." error with that line.
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,046
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:

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,046
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
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,046
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.
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,046
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.
 

Trebor76

Well-known Member
Joined
Jul 23, 2007
Messages
4,435
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:

Ark68

Well-known Member
Joined
Apr 5, 2005
Messages
3,185
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.
 

Forum statistics

Threads
1,077,822
Messages
5,336,566
Members
399,088
Latest member
Swindlestikz

Some videos you may like

This Week's Hot Topics

Top