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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy data from textbox on form 2 to textbox on form 1

Status
Not open for further replies.

sanders720

Programmer
Aug 2, 2001
421
US
I have a flexgrid on form #2, and a textbox on both forms #1 and #2. The code below is on form #2.

When I click the flexgrid, the txtMatlCode.Value is populated based on the item in the row I selected. When I exit the form using the cmdExit function, I am hoping to populate the textbox on the other form with the same information.

Note, both forms are opened (shown) when I execute this part of the code.

Funny thing how it takes hours to do simple things like this, and only minutes to do the real impressive stuff! Anyhow, any help that can be provided is appreciated...

Thanks:



Private Sub msgDataGrid_Click()
Dim lcol As Integer

R = msgDataGrid.Row

For lcol = msgDataGrid.FixedCols To msgDataGrid.Cols - 1
msgDataGrid.Col = lcol
msgDataGrid.CellBackColor = &H80000002
Next lcol

Me.txtMatlCode.Value = msgDataGrid.TextMatrix(R, 1)

End Sub


Private Sub cmdExit_Click()
Dim MACODE As String

MACODE = frmMatlSearch.txtMatlCode.Value
frmPartProp.txtMatlCode.Value = MACODE
Me.hide

End Sub

 
I will assume that your 2 userforms are userform1 and userform2

in userform1 this can be placed anywhere but it is often times effective by using a command button

The original information is in userform1, in textbox1. You want to transfer it to userform2, in textbox1

userform2.textbox1.text = textbox1.text

the = textbox1.text is already in userform1 so we don't have to state it again.

'To hide the userform1 (unloading it or exiting will remove the information - it is better to hide it)
userform1.hide
userform2.show

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top