-
Oct 19th, 2014, 02:22 PM
#1
Thread Starter
Junior Member
How do I transfer data between forms?
Hi, im new here and to programming.
I have 2 forms in my system. On one form there is a combo box with names in it. On the 2nd form there are fields where data is then retrieved from the database. For example, if I select John Smith from the combo box, and go onto the 2nd form, how do I get the data for John Smith to appear on my form? How do I get my system to realise what name has been selected in order to display the correct information?
thank you in advance
-
Oct 19th, 2014, 02:52 PM
#2
Addicted Member
Re: How do I transfer data between forms?
You can make the first form create a text file, and the second form can read the text. You can also have it delete the file upon form close, just so you don't have a big mess on your desktop.
-
Oct 19th, 2014, 03:16 PM
#3
Thread Starter
Junior Member
Re: How do I transfer data between forms?
Originally Posted by NinjaNic
You can make the first form create a text file, and the second form can read the text. You can also have it delete the file upon form close, just so you don't have a big mess on your desktop.
Hiya, i need to use a database, its a requirement
-
Oct 19th, 2014, 03:37 PM
#4
Member
Re: How do I transfer data between forms?
Hello.
I would:
1.- create a public variable in form2, let's say sParameter
2.- in the form2.shown event i would query the database using sParameter
3.- in the form1 button1.click event i would set the sParameter with the text i want to pass out (form2.sparameter=me.textbox1.text)
4.- show the form 2.
But that's just me.
Good luck
Heishiro.
-
Oct 19th, 2014, 06:21 PM
#5
Re: How do I transfer data between forms?
Form 1 takes the selected item, looks up the data - you can keep it in a datarow or put it into a custom class - then make an instance of Form 2, passing it the data, and then showing it.
-tg
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|