Hi all
I have two forms which are being displayed from the MDI Parent form. In the following code I would like to send data from form 1 to form 2.

DsgnForm.InsertOE = txtOrderEntry.Text
                DsgnForm.InsertFN = txtFirstName.Text
                DsgnForm.InsertLN = txtLastName.Text
                DsgnForm.InsertAD = TxtAddress.Text

My problem is when the second form is opened the variables are empty.
How can I send data to the second form.

Thanks

Recommended Answers

All 3 Replies

>Unable to transfer data from one form to another

In order to solve your problem you have to post complete code.

If DsgnForm is a name of Form class then,

DsgnForm.InsertOE = txtOrderEntry.Text
DsgnForm.InsertFN = txtFirstName.Text
DsgnForm.InsertLN = txtLastName.Text
DsgnForm.InsertAD = TxtAddress.Text
DsgnForm.Show()

OR if it is an object of form,

Dim DsgnForm as new Form2
DsgnForm.InsertOE = txtOrderEntry.Text
DsgnForm.InsertFN = txtFirstName.Text
DsgnForm.InsertLN = txtLastName.Text
DsgnForm.InsertAD = TxtAddress.Text
DsgnForm.Show()

thank you for your reply

yes DsgnForm is a name of Form class.

Here is a private sub of form1 named ''CustumerForm'' where i'm trying to send the data to the dsgnform.
hope this helps you help me solve my situation.

Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
        Me.NoteGrid.Visible = False
        Try
            If m_CustomerUpdateCell > 0 Then

                DsgnForm.InsertNote = txtCustumerNote.Text
                Mainform.openDEsignForm() 'Mainform is the MDI Parent
            End If

            If (IsNumeric(txtOrderEntry.Text)) And m_CustomerUpdateCell = 0 Then
                SerchOrderentry()
                If response = vbNo Then Exit Sub
                DsgnForm.InsertOE = txtOrderEntry.Text
                MsgBox(DsgnForm.InsertOE)
                DsgnForm.InsertFN = txtFirstName.Text
                DsgnForm.InsertLN = txtLastName.Text
                DsgnForm.InsertAD = TxtAddress.Text
                DsgnForm.InsertCV = txtCivic.Text
                DsgnForm.InsertCTY = txtCity.Text
                DsgnForm.InsertHome = txtHomePhone.Text
                DsgnForm.InsertCell = txtCellPhone.Text
                DsgnForm.InsertFax = txtFax.Text
                DsgnForm.InsertWrk = txtWorkPhone.Text
                DsgnForm.InsertNote = txtCustumerNote.Text

                btnNext.Enabled = False
                Mainform.openDEsignForm()'Mainform is the MDI Parent
                
            ElseIf txtOrderEntry.Text.Length = 0 Then
                MessageBox.Show("The Order Entry can not be Blank", "CW DEsign", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Exit Sub

            ElseIf Not (IsNumeric(txtOrderEntry.Text)) Then
                MessageBox.Show("The Order Entry must only be Numbers", "CW DEsign", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Exit Sub
           End If
        Catch ex As Exception
            MessageBox.Show("ERROR  " & ex.Message)
        End Try
    End Sub

Thanks Adapost
I have solveded it.
I created a Module then I sent the values from form 1 to the Module.
When the 2nd form is open it recals the values from the Module

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.