Populate Textbox values to Textbox from unrelated table

Software vb.net & Sql Server 2005"
I need sample code on how to Populate Textbox value to Textbox from unrelated table?

Thanks!
dave_skyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Not enough info. How are you getting the data from the database?
What does this mean, "Populate Textbox value to Textbox from unrelated table?"
What type of application are you developing?
Can you please post the code you are using.
dave_skyAuthor Commented:
Developing a Windows form application using a dataset to access the database.

tblWorkorder has TextboxA to be filled with tblChecklists TextboxB value using buttonclick event.
Fernando SotoRetiredCommented:
So you are using a DataSet and a DataTable object to organize your data from the database. So your DataTable may have many rows that were returned by the SQL query.

I am assuming that TextboxA and TextboxB are Windows Form TextBox objects placed on the form. I am also assuming that tblWorkorder and tblChecklists are each a DataTable object that are assigned to the DataSet that hold the data from the database. I can not understand what this means, "tblWorkorder has TextboxA to be filled with tblChecklists TextboxB value using buttonclick event.", can you explain this in a bit more detail?
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

dave_skyAuthor Commented:
You are correct on your assumptions...

I need to copy a value from TextboxA on frmExample1 to TextboxB on frmExample2 with an event.
David Johnson, CD, MVPOwnerCommented:
TextboxB.text = TextboxA.text  doesn't work for you?
Fernando SotoRetiredCommented:
Because the two TextBox's are on two different forms you need to save a reference to the second form so that when you want access to the form2 controls you use its reference and the control and property you want as shown below.

Public Class frmExample1

    '' Create a form level variable which make it available to all code in this Form
    Dim frm2 As frmExample2

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        
        '' Create the frmExample2 form and assign it to the class level variable and show the form
        frm2 = New Form2()
        frm2.Show()
        
        '' Now when you want to assign the value of TextBoxA to TextBoxB
        '' you can do this.
        frm2.TextBoxB.Text = TextBoxA.Text

    End Sub

End Class

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dave_skyAuthor Commented:
Thanks for your help!
Fernando SotoRetiredCommented:
Not a problem, glad to help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.