Is it possible to pass a variable set in one form to another?
Printable View
Is it possible to pass a variable set in one form to another?
Yes, passing data between forms is asked several times a week, and doing a forum search here will turn up tons of results and answers to this. ;)
I did some looking around and tried something like:
But it says:Code:Public Class frm2
Private Sub frm2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label6.Text = frm1.id
End Sub
End Class
Quote:
Error 105 'id' is not a member of 'Project1.frm1'.
Yes. I did from a search form.
In this case I passed the variable to the form I wanted the variable in and then closed the search form.Code:Private Sub DataGridView1_CellClick1(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
DataGridView1.CurrentCell = DataGridView1(0, DataGridView1.CurrentCell.RowIndex)
frmBookingForm.txtAccountNo.Text = DataGridView1.CurrentCell.Value
Me.Close()
End Sub
Does my last post make sense?
What is frm1.id supposed to be referencing?
It references the first originating form and its variable.
What is the variable id, a string, a numeric value, a control name?????
id is a variable from the previous form which is a field resulting from a sql statement.
And what is id displayed in on your frm1?
you could do
Label6.Text = frm1.TextBoxID.Text
or
Label6.Text = frm1.LabelID.Text
or
Label6.Text = frm1.cboID.SelectedText