Results 1 to 5 of 5

Thread: How do I transfer data between forms?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2014
    Posts
    29

    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

  2. #2
    Addicted Member NinjaNic's Avatar
    Join Date
    Dec 2013
    Location
    Earth
    Posts
    230

    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.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2014
    Posts
    29

    Re: How do I transfer data between forms?

    Quote Originally Posted by NinjaNic View Post
    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

  4. #4
    Member
    Join Date
    Jun 2011
    Posts
    36

    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.

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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
  •  



Click Here to Expand Forum to Full Width