I have userform1 with a textbox1 and space on the form is limited. I am trying to create an interactive/editable 'pop-up' to give the user a larger space to enter/edit text in textbox1. I created a mini userform2 with textbox2. I added a small commandbutton1 to userform1 that opens userform2, which works fine. I want textbox1 and textbox2 to mirror each other. As text is added/deleted/edited in one, the same occurs in the other. I thought this would be easy, but I can't even get text from textbox1 to appear in textbox2. Here is what I've tried
Private Sub commandbutton1_Click() 'userform1 module
Dim n As userform2
Set n = New userform2
n.Show 'works
userform2.textbox2.Text = userform1.textbox1.Text 'not working
End Sub
Private Sub Userform_Initialize() 'userform2 module
userform2.textbox2.Text = userform1.textbox1.Text 'not working
End Sub
Private Sub textbox2_Change() 'tried in userform1 and userform2 modules
userform1.textbox1.Text = userform2.textbox2.Text 'not working
End Sub
Private Sub textbox1_Change() 'tried in userform1 and userform2 modules
userform2.textbox2.Text = userform1.textbox1.Text 'not working
End Sub
EDITED
Userform1 contains textbox1 and commandbutton1
Userform2 contains textbox2
I was able to get textbox2 to match textbox1, but not the other way around. Also, I'm not able to keep userform2 in front. For example, if I 'touch' or 'click' on userform1, userform2 disappears behind userform1.
'code in userform1 module
Private Sub commandbutton1_Click()
Dim N As userform2
Set N = New userform2
N.Show
End Sub
Private Sub textbox1_Change() 'Works! If I type in textbox1
userform2.textbox2.Text = Me.textbox1.Text
End Sub
'code in userform 2 module. Not able to keep userform2 in front of userform1 if I 'touch' or 'click' on userform1
Private Sub UserForm_Initialize()
Me.textbox2.Text = userform1.textbox1.Text
Me.StartUpPosition = 0
Me.Left = Application.Left + (0.5 * Application.Width) - (0.5 * Width)
Me.Top = Application.Top + (0.5 * Application.Height) - (0.5 * Height)
End Sub
Private Sub textbox2_Change() 'If I type in textbox2, it does NOT appear in textbox1
userform1.textbox1.Text = Me.textbox2.Text
End Sub
