Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to share dataset among two forms?

Status
Not open for further replies.

gundie

Programmer
Feb 5, 2004
69
US
I'm new to VB2008 and SQL Server, and need some help. I have two forms (frmCustomer and frmDetail). The frmCustomer has a datagridview containing general data of customers, and a button to open frmDetail, which contains each customers detail information. All data modification is done on frmDetail (add, delete, and edit). Currently, both forms are binded to the dataset (same table).

When the two forms are loaded, each form performs a FILL function that retrieves the data from SQL Server. In addition, all modifications done on frmDetail does not show up on frmCustomer until I perform the FILL function again on both forms. I think I'm doing redundant work. Seems like I'm maintaining 2 sets of data from the same table, and I think I'm doing more work than I have to. I'm sure there are ways to make this easier, such as bind both forms to a single dataset, so I don't have to do everything twice.

How do I do that?

I'm hope I'm explaining my situation clearly.
 

Read about the Scope.

Your dataset is (probably) declared in the Form as Private, so it is ‘alive’ in this Form only and not available anywhere else. What you can do it declare the dataset in the standard Module as Public – this way you can access it from any of your Forms, and if you modify it in Form1, it will be changed when you access it from Form2, and vice versa (or is it versa vice? :) )


Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top