Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Populate Userform2 Textbox with Combobox Value Userform1

0

So I don't even know how to start this but I'm trying to do a code on my own and to start off I want to populate a textbox that's on a different userform with the combobox value on another userform. For instance when I select a customer on my first userform I want the customer number to populate a textbox on another userform when I select to open that userform.  Is this possible? Thank you in advance.

Answer
Discuss

Answers

0
Selected Answer

Hi Divinedar

Yes it's possible (and it would help if you attach a file but I've used your previous file to demonstrate).

In the attached version of your previous file, I've rearranged your UserForm FrmForm to add a purple button stating "Launch Customer Notes" (and called Cb_CustNotes) below the Customer Number ComboBox.

When you click that, it triggers this to launch a new form:

Private Sub Cb_CustNotes_Click()



UF_CustNotes.Show



End Sub

That form (Cb_CustNotes) is then initilized to write the value from Customer Number on FrmForm to both a label and an editable text box:

Private Sub UserForm_Initialize()

With Me
    .LB_Cust.Caption = frmForm.cboCustNo.Text
    .TB_Notes.Text = frmForm.cboCustNo.Text & " (Comment added " & Now & "): "
End With

End Sub

I leave you to position the second userform, do other actions you need.

Hope this helps.

Discuss

Discussion

I got this one to work but I'm going to do another question because I have another event to add to this.  The code I got to work that I'd been working on the last few days is this
Private Sub cmdOpGnPrd_Click()

'Set screens to Full Screen

Dim xlws As XlWindowState
xlws = Application.WindowState
Application.WindowState = xlMaximized

With frmGunParts
    .Top = Application.Top
    .Left = Application.Left
    .Width = Application.Width
    .Height = Application.Height
End With

'Add Combobox value from Customer_info userfrom to label box on frmGunParts userform

MyVal = frmForm.cboCustNo.Value
frmGunParts.txtCustupdate.Value = MyVal

'Show frmGunParts userform before closing userFrom1 (Customer_Info frmForm)

frmGunParts.Show

Unload Me ' UserForm1 "frmForm"

Application.WindowState = xlws
End Sub


The one  you wrote is usable for another event I have.  Thank you so much for your help.
Divinedar (rep: 20) Jan 22, '23 at 2:41 pm
Thanks for selecting my answer, Divinedar. Hope I can help you with your follow-up question too.
John_Ru (rep: 6102) Jan 22, '23 at 4:07 pm
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login