Populating fields on a form in VB 2005

I have an app in VB2005 with SQL back end. It has 2 forms so far. On the first form (frm1) I added a datatable to the form. I added some fields from that table to the form via drag-and-drop from the DataSource explorer. I want to open frm2 and use other fields from the same datatable as frm1, again adding fields by drag-and-drop.

The question: Do I have to do another .Fill for frm2 or can I somehow tap into the table that was filled in frm1 If I can tap into it, I could use a code example.

Thanks from a nooB.




Answer this question

Populating fields on a form in VB 2005

  • oguime

    This encapsulation means that you should be able to reuse this form elsewhere without a dependency on other forms.

    Sometimes this is important.


  • Chancetribe

    Thanks spotty. If you recognize my name, you know you posted some examples on passing parameters and arrays recently. They have work well.

    My app actually has 3 forms now: frmSearch, frm1 and frm2. 2 more will be added, all of them read-only and using fields from the same master table. I just wanted to make sure there wasn't some simple solution I was missing that would save time and coding. It looks like your first suggestion above will be best for me since I am familiar with it.

    Thanks again.



  • meher666

    I suppose you could do either.

    You could pass a ID or something from the first form to the second form by way of a property and then use this to populate fill a dataset on the second form which you could bind to.

    or

    You could pass the a datarow from the first form to the second form again by way of a property.

    What are you intending on doin on the second form - updates to the database. If so, then using the first approach may prove beneficial as it sort of encapsulates the entire functionality within the form.


  • Populating fields on a form in VB 2005