Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filling textbox on Form1 with combobox text from Form2

Status
Not open for further replies.

insanevbr

Programmer
Oct 10, 2002
8
0
0
US
Hi,

I am trying to populate information selected from a combobox on frmTradeListing to a textbox on frmTradeSummary.

When I select the combobox it closes frmTradeListing but then the text doesn't transfer to the textbox on frmTradeSummary.

Here is a sample of the code:

Private Sub cboMyCombo_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboMyCombo.SelectedIndexChanged
Dim frmMain as New frmTradeSummary
With Me
frmMain.txtTrades.Text = .cboMyCombo.Text
End With
End Sub

Please help.

 
I'm not sure how to reference it directly, but here is one way to acomplish what you are trying.

'in frmTradeSummary
Public Shared sValue as String
Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
txtTrades.Text = sValue
End Sub

'in frmTradeListing
Private Sub cboMyCombo_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboMyCombo.SelectedIndexChanged
Dim frmMain as New frmTradeSummary
frmMain.sValue = cboMyCombo.Text
End Sub


Kris
 
Is frmMain open when you do this? If it is then you need to access the old already open instance of the form.

When you typed Dim frmMain as New frmTradeSummary you made a brand new instance of that form.

do something like me.parent to get the other form. If frmTradeListing is opened by frmMain that is. How you point to the other form depends on how you opened it and such.
Hope this points you in the right direction. That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top